Repository navigation
Expand file tree
/
Copy pathcodefresh.yml
More file actions
130 lines (119 loc) · 4.21 KB
/
Copy pathcodefresh.yml
File metadata and controls
130 lines (119 loc) · 4.21 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
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 CICD_REPO="${{CF_VOLUME_PATH}}/m2_repository"
- cf_export GPG_IMPORT_COMMAND="cat <(echo -e '${{GPG_PRIVATE_KEY}}') | gpg --batch --import" --mask
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\" -s ${{CF_VOLUME_PATH}}/${{CF_REPO_NAME}}/settings.xml"
TagReleaseName:
title: Setup RELEASE_NAME variable with tag
stage: 'setup'
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
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
ReleaseProperties:
title: Setup release build
stage: 'setup'
image: alpine/git
when:
condition:
all:
releaseNameNotDefined: "${{TAG_REPO}} == true"
commands:
- cf_export MVN_SET_VERSION="${{MVN_CLI_OPT}} versions:set-property -DnewVersion=${{RELEASE_NAME}}"
BranchProperties:
title: Setup branch build
stage: 'setup'
image: alpine/git
when:
condition:
all:
releaseNameNotDefined: "${{TAG_REPO}} == false"
commands:
- cf_export MVN_SET_VERSION="${{MVN_CLI_OPT}} versions:update-property -DnewVersion=[${{RELEASE_NAME}}] -DallowSnapshots=true -DallowDowngrade=true"
# Exports GCP_ACCESS_TOKEN, which the Artifact Registry servers in settings.xml
# use as their Basic auth password, by workload identity federation rather than
# a service account key. Step definition lives in the REGnosys/scripts repo, at
# codefresh/step-types/gcp-oidc-auth.yml.
#
# Last of the setup steps on purpose: the token lasts an hour from here, and
# everything that spends it is below.
Authenticate:
title: Federate into GCP
stage: 'setup'
type: regnosysops/gcp-oidc-auth:1.0.1
arguments:
WIF_PROVIDER: ${{GCP_WIF_PROVIDER_CODEFRESH_AUDIENCE}}
SERVICE_ACCOUNT: ${{GCP_CODEFRESH_SERVICE_ACCOUNT}}
Build:
title: Maven build
stage: 'build'
fail_fast: true
image: maven:3.9.16-eclipse-temurin-21-alpine
working_directory: ./
commands:
- bash -c "${{GPG_IMPORT_COMMAND}}"
- mvn ${{MVN_CLI_OPT}} versions:set -DnewVersion=${{RELEASE_NAME}} -DallowSnapshots=true -P regnosys
- mvn ${{MVN_SET_VERSION}} -Dproperty=regnosys.bundle.version -P regnosys
- 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 -U -B ${{MVN_CLI_OPT}} clean install org.sonatype.central:central-publishing-maven-plugin:0.7.0:publish -P release,regnosys
FailPipeline:
stage: 'finalise'
title: Fail pipeline on failure
image: codefresh/cli
when:
condition:
any:
buildFailure: steps.Build.result == 'failure'
commands:
- exit 1
TagRepo:
title: Tag git repo with release name
stage: 'finalise'
image: alpine/git
when:
condition:
all:
buildPassed: steps.BuildRelease.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/REGnosys/${{CF_REPO_NAME}}.git "+refs/tags/*:refs/tags/*"
- git tag ${{RELEASE_NAME}}
- git push https://${{REGNOSYS_OPS}}:${{REGNOSYS_OPS_TOKEN}}@github.com/REGnosys/${{CF_REPO_NAME}}.git ${{RELEASE_NAME}}