-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
53 lines (49 loc) · 1.66 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
#!/usr/bin/env groovy
node('python311') {
container('run') {
def tag = ''
def gitTag = ''
boolean createdTag = false
try {
stage('Checkout') {
checkout scm
gitTag = sh(script: 'git tag -l --contains HEAD', returnStdout: true).trim()
}
if (gitTag != '') {
tag = gitTag
}else if (env.BRANCH_NAME == 'main') {
stage('create tag') {
sshagent(credentials: ['jenkins-kiro-github']) {
tag = sh(
script: 'fnxctl git bump-tag',
returnStdout: true
).trim()
}
createdTag = true
echo 'new tag: ' + tag
}
}
if (tag != '') {
stage('Generate and push docker image') {
echo "Building with docker tag ${tag}"
docker.withRegistry('https://quay.io', 'docker-registry') {
sh("fnxctl build backend ${tag}")
}
}
stage('Trigger deploy to dev') {
build job: 'infosec/kiro/deploy-dev', parameters: [
[$class: 'StringParameterValue', name: 'GIT_TAG', value: tag]
], wait: false
}
}
} catch (err) {
if (createdTag) {
sshagent(credentials: ['jenkins-kiro-github']) {
sh("git tag -d ${tag}")
sh("git push --delete origin ${tag}")
}
}
throw err
}
}
}