-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile3Oct
More file actions
55 lines (34 loc) · 752 Bytes
/
Jenkinsfile3Oct
File metadata and controls
55 lines (34 loc) · 752 Bytes
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
pipeline{
environment {
registry = "omkarbolake94/my-images"
DOCKER_CRED = credentials('dockerhub2')
cred = 'dockerhub2'
}
agent{
dockerfile {args '--user root -v /var/run/docker.sock:/var/run/docker.sock'}
}
stages{
stage('Build Code'){
steps{
sh 'mvn clean package'
}
}
stage('Build and push Docker Image'){
environment {
DOCKER_IMAGE = "omkarbolake94/my-images:$BUILD_NUMBER"
REGISTRY_CREDENTIALS = credentials('dockerhub')
}
steps{
script{
sh 'echo "$DOCKER_IMAGE" '
sh 'docker build -t "${DOCKER_IMAGE}" -f Dockerfile2 .'
def dockerImage = docker.image("${DOCKER_IMAGE}")
docker.withRegistry('', "dockerhub") {
dockerImage.push("V$BUILD_NUMBER")
dockerImage.push('latest')
}
}
}
}
}
}