-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
58 lines (46 loc) · 1.21 KB
/
Copy pathJenkinsfile
File metadata and controls
58 lines (46 loc) · 1.21 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
54
55
56
57
58
pipeline {
agent any
environment {
docker_username = "nwajienelson"
}
stages{
stage("Build Image"){
steps{
sh "sudo docker build -t gitops:${env.BUILD_ID} ."
sh "sudo docker images"
}
}
stage("Image Scanning"){
steps{
echo "Image Scanned and passed"
}
}
stage("Approval after Scan"){
steps{
timeout(time:5, unit:'DAYS'){
input message: 'Approval for Image Tag and Push'
}
}
}
stage("Tag Image"){
steps{
echo "retag the image for the final push"
sh "sudo docker tag gitops:${env.BUILD_ID} nwajienelson/gitops:${env.BUILD_ID}"
}
}
stage("Push Image"){
steps{
withCredentials([string(credentialsId: 'docker_password', variable: 'docker_password')]) {
sh 'docker login -u $docker_username -p $docker_password'
sh "docker push nwajienelson/gitops:${env.BUILD_ID}"
}
}
}
stage("Email Notification"){
steps{
echo "Email has been sent"
// emailext body: 'This is Build Success', subject: 'Build Success', to: 'nelson.nwajie@gmail.com'
}
}
}
}