-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodefresh.yml
More file actions
148 lines (137 loc) · 4.69 KB
/
codefresh.yml
File metadata and controls
148 lines (137 loc) · 4.69 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
version: "1.0"
stages:
- setup
- build
- finalise
steps:
main_clone:
stage: 'setup'
title: Cloning main repository...
type: git-clone
git: rosetta-models
repo: "${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}"
revision: "${{CF_REVISION}}"
BranchReleaseName:
stage: 'setup'
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
TagReleaseName:
stage: 'setup'
title: Setup RELEASE_NAME variable with tag
image: alpine/git
when:
condition:
all:
releaseNameNotDefined: "${{TAG_REPO}} == true"
commands:
- cf_export RELEASE_NAME=${{TAG_NAME}}
MvnSettings:
stage: 'setup'
title: Setup Maven settings
image: alpine/git
commands:
- cf_export MVN_CLI_OPT="-Dmaven.repo.local=\"${{CF_VOLUME_PATH}}/${{CF_REPO_NAME}}_m2/repository\""
- echo $MVN_CLI_OPT
BranchProperties:
stage: 'setup'
title: Setup branch build
image: alpine/git
when:
condition:
all:
releaseNameNotDefined: "${{TAG_REPO}} == false"
commands:
- cf_export MVN_SET_VERSION="${{MVN_CLI_OPT}} versions:set -DnewVersion=${{RELEASE_NAME}}"
ReleaseProperties:
stage: 'setup'
title: Setup release build
image: alpine/git
when:
condition:
all:
releaseNameNotDefined: "${{TAG_REPO}} == true"
commands:
- cf_export MVN_SET_VERSION="${{MVN_CLI_OPT}} versions:set -DnewVersion=${{RELEASE_NAME}}"
- cf_export GH_TOKEN=${{REGNOSYS_OPS_TOKEN}}
- cf_export GITHUB_RELEASE_API="https://api.github.com/repos/${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/releases"
- >-
cf_export GITHUB_API_CURL="curl -L -X POST -H \"Accept: application/vnd.github+json\" -H \"Authorization: Bearer ${{REGNOSYS_OPS_TOKEN}}\""
Build:
stage: 'build'
title: Maven build
fail_fast: false
image: maven:3.9.11-eclipse-temurin-21
working_directory: ./
commands:
- echo "${{ARTIFACT_REGISTRY_SA_KEY}}"|base64 -d>"${{CF_VOLUME_PATH}}"/sa
- export GOOGLE_APPLICATION_CREDENTIALS="${{CF_VOLUME_PATH}}"/sa
- mvn ${{MVN_CLI_OPT}} versions:set -DnewVersion=${{RELEASE_NAME}}
- mvn ${{MVN_CLI_OPT}} clean deploy
NotifySlackOnFail:
stage: 'finalise'
title: Trigger Slack dev channel notification if main build failed
image: codefresh/cli
when:
branch:
only:
- main
condition:
any:
buildNormalFailed: steps.Build.result == 'error'
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:
stage: 'finalise'
title: Fail pipeline if the Maven build failed
image: codefresh/cli
when:
condition:
any:
normalBuildFailure: steps.Build.result == 'failure'
commands:
- exit 1
TagRepo:
stage: 'finalise'
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/${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}.git "+refs/tags/*:refs/tags/*"
- git tag ${{TAG_NAME}}
- git push https://${{ROSETTA_MODELS_USER}}:${{ROSETTA_MODELS_PWD}}@github.com/${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}.git ${{TAG_NAME}}
CreateRelease:
stage: 'finalise'
title: Create Release
image: curlimages/curl
when:
condition:
all:
isRelease: "${{TAG_REPO}}"
buildPassed: steps.TagRepo.result == 'success'
commands:
- echo CreateRelease
- >-
${{GITHUB_API_CURL}} ${{GITHUB_RELEASE_API}}
-d '{
"tag_name": "${{RELEASE_NAME}}",
"generate_release_notes": true
}'