forked from jc21/docker-rpmbuild-centos7
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
executable file
·57 lines (55 loc) · 1.42 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
pipeline {
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
disableConcurrentBuilds()
}
agent {
label 'docker'
}
environment {
IMAGE = "rpmbuild-centos7"
TAG = "latest"
TEMP_IMAGE = "rpmbuild7_${TAG}_${BUILD_NUMBER}"
}
stages {
stage('Build') {
steps {
ansiColor('xterm') {
sh 'docker build --pull --no-cache --squash --compress -t ${TEMP_IMAGE} .'
}
}
}
stage('Publish') {
steps {
ansiColor('xterm') {
// Dockerhub
sh 'docker tag ${TEMP_IMAGE} docker.io/jc21/${IMAGE}:${TAG}'
withCredentials([usernamePassword(credentialsId: 'jc21-dockerhub', passwordVariable: 'dpass', usernameVariable: 'duser')]) {
sh "docker login -u '${duser}' -p '${dpass}'"
sh 'docker push docker.io/jc21/${IMAGE}:${TAG}'
sh 'docker rmi docker.io/jc21/${IMAGE}:${TAG}'
}
}
}
}
}
triggers {
githubPush()
}
post {
success {
build job: 'Docker/docker-rpmbuild-centos7/golang', wait: false
build job: 'Docker/docker-rpmbuild-centos7/devtools7', wait: false
build job: 'Docker/docker-rpmbuild-centos7/rust', wait: false
juxtapose event: 'success'
sh 'figlet "SUCCESS"'
}
failure {
juxtapose event: 'failure'
sh 'figlet "FAILURE"'
}
always {
sh 'docker rmi ${TEMP_IMAGE}'
}
}
}