forked from GameZoneHacker/node-js-dummy-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
53 lines (51 loc) · 1.42 KB
/
Jenkinsfile
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 = "sc0rpion/my-node-app"
registryCredential = 'dockerhub'
}
stages {
stage('Cloning Git') {
steps {
git 'https://github.com/GameZoneHacker/node-js-dummy-test.git'
}
}
stage('Building Docker Image') {
steps {
script {
docker.withRegistry('https://registry.hub.docker.com', 'dockerhub') {
def dockerImage = docker.build("${registry}")
}
}
}
}
stage('Security Scan') {
steps {
script {
// Example using Trivy for security scan
sh "docker run --rm -v /var/run/docker.sock:/var/run/docker.sock aquasec/trivy:latest image ${registry}"
}
}
}
stage('Deploying Image') {
steps {
script {
docker.withRegistry('https://registry.hub.docker.com', 'dockerhub') {
def dockerImage = docker.image("${registry}")
dockerImage.push()
}
}
}
}
stage('Clean up') {
steps {
sh "docker rmi ${registry}"
}
}
}
post {
always {
cleanWs()
}
}
}