-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathJenkinsfile
44 lines (44 loc) · 1.24 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
pipeline {
agent {
label 'docker'
}
options {
timestamps()
}
environment {
GITHUB_USER_ID = '2b98d5a0-65f8-4961-958d-ad3620541256'
ALIYUN_USER_ID = '06989ce7-86fb-43ca-aec0-313d260af382'
IMAGE_NAME = 'registry.cn-shenzhen.aliyuncs.com/tendcode/izone:lts'
}
stages {
stage('Clone sources') {
options {
timeout(time: 30, unit: 'SECONDS')
}
steps {
git (credentialsId: "${GITHUB_USER_ID}", url: 'https://github.com/Hopetree/izone.git', branch: 'master')
}
}
stage('Build image') {
steps {
script {
docker.build("${IMAGE_NAME}")
}
}
}
stage('Push image') {
steps {
withDockerRegistry(credentialsId: "${ALIYUN_USER_ID}", url: 'http://registry.cn-shenzhen.aliyuncs.com') {
sh "docker push ${IMAGE_NAME}"
}
}
}
}
post {
always {
sh "docker images|grep '<none>'|awk '{print \$3}'|xargs docker image rm > /dev/null 2>&1 || true"
sh "docker images"
cleanWs()
}
}
}