-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
169 lines (146 loc) · 7.67 KB
/
Jenkinsfile
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/usr/bin/env groovy
pipeline {
agent none
environment {
tag = VersionNumber(versionNumberString: '${BUILD_TIMESTAMP}');
// job environment variables
BUILD_ENV = "${build_stream}"
// this is a result of a backwards-incompatible change from JENKINS-24380
BUILD_ID = "${VersionNumber(projectStartDate: '1970-01-01', versionNumberString: '${BUILD_DATE_FORMATTED, \"yyyy-MM-dd_H-m-s\"}')}"
}
parameters {
booleanParam(name: 'deploy',
defaultValue: false,
description: 'Whether or not to deploy this new build to the environment selected below.')
choice(name: 'branch',
choices: ['main','feature/shutdown_notify'],
description: 'The source branch to compile.')
choice(name: 'env',
choices: ['mob_qa','mob_pro','beta_qa','stage.qa','api.qa','api.pro'],
description: 'If deploying, which ansible environment to deploy to. Determines deployment target')
choice(name: 'dog_env',
choices: ['qa','pro'],
description: 'If deploying, which dog environment to deploy to. Determines which dog_trainer this build will connect to')
string(name: 'target',
defaultValue: '',
description: 'The target host/group.')
string(name: 'flags',
defaultValue: '--tags upgrade',
description: 'ansible flags')
choice(name: 'erlang_version',
choices: ['24.3.4.2','25.3.2.12','23.3.4.3'],
description: 'The erlang_version dog_agent_ex will be built with')
choice(name: 'release_path',
choices: ['deployable/rel/dog_agent/','test/rel/dog_agent/'],
description: 'deployable or test type of artifact')
}
stages {
stage('Matrix Build') {
matrix {
agent {
docker { image "${DOCKER_IMAGE}" }
}
axes {
axis {
name 'DOCKER_IMAGE'
values 'relaypro/erlang-focal:master-latest',
'relaypro/erlang-xenial:master-latest',
'relaypro/erlang-jammy:master-latest',
'relaypro/erlang-noble:master-latest'
}
}
stages {
stage ('Checkout') {
steps {
checkout([$class: 'GitSCM', branches: [[name: '${branch}']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'admin', url: 'https://github.com/relaypro-open/dog_agent.git']]])
}
}
stage('Build') {
steps{
sh """#!/bin/bash -x
echo "env: \$env"
echo "dog_env: \$dog_env"
if [[ \$env == *qa ]]; then
build_env="qa"
elif [[ \$env == *pro ]]; then
build_env="pro"
elif [[ \$env == *dev ]]; then
build_env="dev"
fi
if [[ \$DOCKER_IMAGE == 'relaypro/erlang-xenial:master-latest' ]]; then
build_suffix='ubuntu'
elif [[ \$DOCKER_IMAGE == 'relaypro/erlang-focal:master-latest' ]]; then
build_suffix='ubuntu-20-04'
elif [[ \$DOCKER_IMAGE == 'relaypro/erlang-jammy:master-latest' ]]; then
build_suffix='ubuntu-22-04'
elif [[ \$DOCKER_IMAGE == 'relaypro/erlang-noble:master-latest' ]]; then
build_suffix='ubuntu-24-04'
fi
ls /opt/kerl/lib
. /opt/kerl/lib/\$erlang_version/activate
which erl
echo "build_env: \$build_env"
rm -rf _build
export erts_version=\$(scripts/erts_version.escript)
config/make_dog_start.sh
sed -i "s/.* %% relflow-release-version-marker/\\"$dog_env-$BUILD_ID\\" %% relflow-release-version-marker/g" rebar.config
sed -i "s/NOT_SET/$dog_env-$BUILD_ID/"g config/sys.config.etc
#rm -f rebar3
#wget https://s3.amazonaws.com/rebar3/rebar3 && chmod +x rebar3
./rebar3 as \$dog_env tar
mv _build/*/rel/dog/dog-\$dog_env-\$BUILD_ID.tar.gz \$dog_env-\$BUILD_ID.\$build_suffix.tar.gz
"""
}
post {
success {
archiveArtifacts allowEmptyArchive: false, artifacts: '*.tar.gz', caseSensitive: true, defaultExcludes: true, fingerprint: false
}
}
}
stage('Upload artifact to S3') {
steps {
withAWS(credentials: 'aws-iam-user/product-jenkins-artifact-uploads') {
s3Upload bucket:'product-builds', path: 'dog/' + params.release_path, includePathPattern: '*.tar.gz'
}
}
}
stage('Cleanup') {
steps {
cleanWs(cleanWhenNotBuilt: false,
deleteDirs: true,
disableDeferredWipeout: true,
notFailBuild: true)
}
}
stage('Deploy') {
when {
expression { params.deploy == true }
}
steps {
build job: '/playbyplay/pbp-common-deploy', parameters: [
string(name: 'deployEnv', value: "${params.env}"),
string(name: 'app', value: 'dog'),
string(name: 'target', value: "${params.target}"),
//string(name: 'ansibleFlags', value: "--tags ci -ebuild_stream=${params.buildStream}"),
string(name: 'ansibleFlags', value: "-e release_path=${params.release_path} -eerlang_version=$erlang_version ${params.flags}"),
string(name: 'release_path', value: "${params.release_path}"),
string(name: 'erts_version', value: "${params.erts}")
]
}
}
}
}
}
}
post {
changed {
emailext(
to: '[email protected]',
body: '${DEFAULT_CONTENT}',
mimeType: 'text/html',
subject: '${DEFAULT_SUBJECT}',
replyTo: '$DEFAULT_REPLYTO'
)
}
}
}