-
Notifications
You must be signed in to change notification settings - Fork 4
/
codefresh.yml
101 lines (94 loc) · 3.27 KB
/
codefresh.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
version: "1.0"
steps:
main_clone:
title: Cloning main repository...
type: git-clone
git: rosetta-models
repo: "${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}"
revision: "${{CF_REVISION}}"
TagReleaseName:
title: Setup RELEASE_NAME variable with tag
image: alpine/git
when:
condition:
all:
releaseNameNotDefined: "${{TAG_REPO}} == true"
commands:
- cf_export RELEASE_NAME=${{TAG_NAME}}
BranchReleaseName:
title: Setup RELEASE_NAME variable with branch name
image: alpine/git
when:
condition:
all:
releaseNameNotDefined: "${{TAG_REPO}} == false"
commands:
- cf_export RELEASE_NAME=${{GLOBAL_RELEASE_VERSION}}.${{CF_BRANCH_TAG_NORMALIZED}}-SNAPSHOT
Build:
title: Maven build
fail_fast: false
image: maven:3.8.5-openjdk-11
working_directory: ./
commands:
- echo "${{ARTIFACT_REGISTRY_SA_KEY}}"|base64 -d>"${{CF_VOLUME_PATH}}"/sa
- export GOOGLE_APPLICATION_CREDENTIALS="${{CF_VOLUME_PATH}}"/sa
- mvn versions:set -DnewVersion=${{RELEASE_NAME}}
- mvn -U clean deploy
NotifySlackOnFail:
title: Trigger Slack dev channel notification if master build failed
image: codefresh/cli
when:
branch:
only:
- master
steps:
- name: Build
on:
- failure
commands:
- export SAFE_COMMIT_AUTHOR='${{CF_COMMIT_AUTHOR}}'
- export COMMIT_AUTHOR=${SAFE_COMMIT_AUTHOR:-MissingAuthor}
- export SAFE_REPO_NAME='${{CF_REPO_NAME}}'
- export REPO_NAME=${SAFE_REPO_NAME:-NoRepo}
- export SAFE_COMMIT_MESSAGE='${{CF_COMMIT_MESSAGE}}'
- export COMMIT_MESSAGE=${SAFE_COMMIT_MESSAGE:-NoCommitMsg}
- echo Author is $SAFE_COMMIT_AUTHOR and commit msg is $SAFE_COMMIT_MESSAGE and repo is $SAFE_REPO_NAME
- echo After substitution author is $COMMIT_AUTHOR and commit msg is $COMMIT_MESSAGE and repo is $REPO_NAME
- codefresh run slack-notifier -v REPO_NAME="${REPO_NAME}" -v COMMIT_AUTHOR="${COMMIT_AUTHOR}" -v COMMIT_MESSAGE="${COMMIT_MESSAGE}" --detach
FailPipeline:
title: Fail pipeline if the Maven build failed
image: codefresh/cli
when:
steps:
- name: Build
on:
- failure
commands:
- exit 1
TagRepo:
title: Tag git repo with release name
image: alpine/git
when:
condition:
all:
buildPassed: steps.Build.result == 'success'
isRelease: "${{TAG_REPO}}"
commands:
- echo This is a release build, tag repos with release name [${{TAG_NAME}}]
- git fetch --prune https://${{ROSETTA_MODELS_USER}}:${{ROSETTA_MODELS_PWD}}@github.com/rosetta-models/demo.git "+refs/tags/*:refs/tags/*"
- git tag ${{TAG_NAME}}
- git push https://${{ROSETTA_MODELS_USER}}:${{ROSETTA_MODELS_PWD}}@github.com/rosetta-models/demo.git ${{TAG_NAME}}
StartNextBuild:
title: Build rosetta-ingest if on master
image: codefresh/cli
when:
branch:
only:
- master
condition:
all:
buildPassed: steps.Build.result == 'success'
variableDefined: "${{TAG_REPO}} == false"
skipNextBuild: "${{SKIP_NEXT_BUILD}} == false"
commands:
- codefresh run REGnosys/rosetta-ingest/rosetta-ingest --branch master --detach