forked from LondheShubham153/node-todo-cicd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
75 lines (66 loc) · 2.1 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
pipeline{
agent any
environment{
SONAR_HOME= tool "Sonar"
}
stages{
stage("Code Checkout"){
steps{
git url:"https://github.com/DevMadhup/node-todo-cicd.git", branch:"master"
}
}
stage("SonarQube Analysis"){
steps{
withSonarQubeEnv("Sonar"){
sh "$SONAR_HOME/bin/sonar-scanner -Dsonar.projectName=nodetodo -Dsonar.projectKey=nodetodo"
}
}
}
stage("SonarQube Quality Gates"){
steps{
timeout(time: 1, unit: "MINUTES"){
waitForQualityGate abortPipeline: false
}
}
}
stage("OWASP Dependency Check"){
steps{
dependencyCheck additionalArguments: '--scan ./', odcInstallation: 'dc'
dependencyCheckPublisher pattern: '**/dependency-check-report.xml'
}
}
stage("Docker Code Build"){
steps{
sh "docker build -t nodeapp ."
}
}
stage("Docker Code Scan: Trivy"){
steps{
sh "trivy image nodeapp"
}
}
stage("Docker Build Push: DockerHub"){
steps{
withCredentials([usernamePassword(credentialsId:"DockerCred",passwordVariable:"dockerhubpass",usernameVariable:"dockerhubname")]){
sh "docker logout"
sh "docker login -u ${env.dockerhubname} -p ${env.dockerhubpass}"
}
}
}
stage("Docker Tag"){
steps{
sh "docker tag nodeapp:latest madhupdevops/nodeapp:latest"
}
}
stage("Code Push to DockerHub"){
steps{
sh "docker push madhupdevops/nodeapp:latest"
}
}
stage("Code Deploy"){
steps{
sh "docker-compose down && docker-compose up -d"
}
}
}
}