-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathJenkinsfile1
31 lines (29 loc) · 1.04 KB
/
Jenkinsfile1
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
def label = "mypod-${UUID.randomUUID().toString()}"
podTemplate(label: label, containers: [
containerTemplate(name: 'docker', image: 'docker', ttyEnabled: true, command: 'cat')
],
volumes: [
hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock')
]) {
node(label) {
try {
container('docker'){
stage('Checkout') {
checkout scm
}
stage('Build & Push Docker image') {
container('docker') {
echo '==============================Build Docker Image======================================='
sh "docker build -t ${env.JOB_NAME}:${GIT_COMMIT} ."
echo '==============================Push Docker Image======================================='
docker.withRegistry("https://docker.io") {
docker.image("${env.JOB_NAME}:${GIT_COMMIT}").push()
}
}
}
}
} catch (e) {
throw e
}
}
}