forked from hellokaton/java11-examples
-
Notifications
You must be signed in to change notification settings - Fork 170
Expand file tree
/
Copy pathJenkinsfile
More file actions
53 lines (46 loc) · 1.19 KB
/
Copy pathJenkinsfile
File metadata and controls
53 lines (46 loc) · 1.19 KB
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
pipeline {
agent any
environment {
REGISTRY = "localhost:5000"
IMAGE_NAME = "java11-examples"
IMAGE_TAG = "${BUILD_NUMBER}"
}
stages {
stage('Checkout') {
steps {
git branch: 'master',
url: 'https://github.com/amitopenwriteup/java11-examples.git'
}
}
stage('Docker Build') {
steps {
sh """
docker build \
-f dockerfile \
-t ${REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG} \
-t ${REGISTRY}/${IMAGE_NAME}:latest \
.
"""
}
}
stage('Docker Push') {
steps {
sh """
docker push ${REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}
docker push ${REGISTRY}/${IMAGE_NAME}:latest
"""
}
}
}
post {
success {
echo "Docker image pushed successfully."
}
failure {
echo "Pipeline failed."
}
always {
sh 'docker image ls | head'
}
}
}