-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile_tagBuilderImage
35 lines (34 loc) · 1.37 KB
/
Jenkinsfile_tagBuilderImage
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
#!groovy
pipeline {
agent {
label "docker"
}
options {
timestamps()
timeout(time: 2, unit: 'HOURS')
buildDiscarder(logRotator(numToKeepStr: '30', artifactNumToKeepStr: '5'))
disableConcurrentBuilds()
}
parameters {
choice choices: ['debian', 'fedora'], description: 'Which image do you want to tag?', name: 'IMAGE_TO_TAG'
string defaultValue: 'latest', description: 'Which existing version to you want to tag?', name: 'IMAGE_VERSION_TO_TAG', trim: true
string defaultValue: '', description: 'Which tag should be set?', name: 'TAG_TO_SET', trim: true
}
stages {
stage('Tag Docker image') {
steps {
script {
withDockerRegistry(credentialsId: 'Docker-Registry') {
sh(
script: '''
docker pull starwarsfan/cmake-builder-${IMAGE_TO_TAG}:${IMAGE_VERSION_TO_TAG}
docker tag starwarsfan/cmake-builder-${IMAGE_TO_TAG}:${IMAGE_VERSION_TO_TAG} starwarsfan/cmake-builder-${IMAGE_TO_TAG}:${TAG_TO_SET}
docker push starwarsfan/cmake-builder-${IMAGE_TO_TAG}:${TAG_TO_SET}
'''
)
}
}
}
}
}
}