forked from REGnosys/rune-common
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodefresh.yml
123 lines (115 loc) · 3.79 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
version: '1.0'
stages:
- setup
- build
- finalise
steps:
main_clone:
title: Cloning main repository...
stage: 'setup'
type: git-clone
git: github
repo: "${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}"
revision: "${{CF_REVISION}}"
SetProperties:
title: Setup build
stage: 'setup'
image: alpine/git
commands:
- cf_export GPG_IMPORT_COMMAND="cat <(echo -e '${{GPG_PRIVATE_KEY}}') | gpg --batch --import" --mask
ReleaseProperties:
title: Setup release build
stage: 'setup'
image: alpine/git
when:
condition:
all:
releaseNameNotDefined: "${{TAG_REPO}} == true"
commands:
- cf_export RELEASE_NAME=${{TAG_NAME}}
SnapshotProperties:
title: Setup snapshot build
stage: 'setup'
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
stage: 'build'
fail_fast: false
image: maven:3.8.5-openjdk-17
working_directory: ./
commands:
- bash -c "${{GPG_IMPORT_COMMAND}}"
- mvn versions:set -DnewVersion="${{RELEASE_NAME}}" -DallowSnapshots=true
- export CI_DEPLOY_USERNAME="${{CI_DEPLOY_USERNAME}}"
- export CI_DEPLOY_PASSWORD="${{CI_DEPLOY_PASSWORD}}"
- export GPG_KEYNAME="${{GPG_KEYNAME}}"
- export GPG_PASSPHRASE="${{GPG_PASSPHRASE}}"
- mvn -s settings.xml -U -B clean deploy -P gpg
NotifySlackOnFail:
title: Trigger Slack dev channel notification if main build failed
stage: 'finalise'
image: codefresh/cli
when:
branch:
only:
- main
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
stage: 'finalise'
image: codefresh/cli
when:
steps:
- name: Build
on:
- failure
commands:
- exit 1
TagRepo:
title: Tag git repo with release name
stage: 'finalise'
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 [${{RELEASE_NAME}}]
- git fetch --prune https://${{REGNOSYS_OPS}}:${{REGNOSYS_OPS_TOKEN}}@github.com/finos/${{CF_REPO_NAME}}.git "+refs/tags/*:refs/tags/*"
- git tag ${{RELEASE_NAME}}
- git push https://${{REGNOSYS_OPS}}:${{REGNOSYS_OPS_TOKEN}}@github.com/finos/${{CF_REPO_NAME}}.git ${{RELEASE_NAME}}
StartNextBuild:
title: Build Rune-testing if on main
stage: 'finalise'
image: codefresh/cli
when:
branch:
only:
- main
condition:
all:
buildPassed: steps.Build.result == 'success'
variableDefined: "${{TAG_REPO}} == false"
skipNextBuild: "${{SKIP_NEXT_BUILD}} == false"
commands:
- codefresh run FINOS/rune-testing --branch main --trigger finos/rune-testing/push --detach