-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile_pipeline_E2E
89 lines (73 loc) · 2.3 KB
/
Jenkinsfile_pipeline_E2E
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
pipeline {
environment {
//This variable need be tested as string
doError = '1'
}
agent any
stages {
stage('Cloning-Git') {
steps{
script{
// Delete workspace before build starts
cleanWs()
// checkout code
checkout scm
}
}
}
stage('SAST Scan') {
steps {
echo "SAST scan.."
build 'security-sast-snyk-plugin'
}
}
stage('Build-Tag-Post2dockerhub ') {
steps{
script{
customImage = docker.build("zia2090406/snake:$BUILD_NUMBER")
docker.withRegistry('https://registry.hub.docker.com', 'docker_hub') {
customImage.push()
}
}
}
}
stage('Docker Image Scan') {
steps {
echo "Docker Image scan.."
build 'security-image-scanner-aquasec'
}
}
stage('Create-Container&-Deploy') {
steps {
sh '''
# stop and remove container if container websnake is running
if [ "$(docker ps -q -f name=websnake)" ]; then
docker stop websnake
docker rm websnake
fi
# remove container if container websnake is stopped but not exited i.r port is still allocated
if [ "$(docker ps -aq -f status=exited -f name=websnake)" ]; then
docker stop websnake
docker rm websnake
fi
# Deploy app on 3000 on container, accessible on 9099/80; mount volume -v local_server_path:container_directory
docker run -d --name websnake -p 80:3000 -v /home/ubuntu/app-test/node-multiplayer-snake/:/app zia2090406/snake:$BUILD_NUMBER
'''
}
}
stage('DAST Scan') {
steps {
echo "DAST scan.."
build 'security-dast-owasp_zap'
}
}
}
post {
always {
echo 'I will always say Hello again!'
//emailext body: "${currentBuild.currentResult}: Job ${env.JOB_NAME} build ${env.BUILD_NUMBER}\n More info at: ${env.BUILD_URL}",
// recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']],
// subject: "Jenkins Build ${currentBuild.currentResult}: Job ${env.JOB_NAME}"
}
}
}