-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
67 lines (59 loc) · 2 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
pipeline {
agent any
environment{
SCANNER_HOME= tool 'sonar-scanner'
}
stages {
stage('git-checkout') {
steps {
git branch: 'main', changelog: false, poll: false, url: 'https://github.com/Daoud-Hussain/Full-Stack-Application.git'
}
}
stage('Sonar Analysis') {
steps {
sh ''' $SCANNER_HOME/bin/sonar-scanner -Dsonar.url=URL_OF_SONARQUBE -Dsonar.login=TOKEN_OF_SONARQUBE -Dsonar.projectName=to-do-app \
-Dsonar.sources=. \
-Dsonar.projectKey=to-do-app '''
}
}
stage('OWASP Dependency Check') {
steps {
dependencyCheck additionalArguments: '--scan ./', odcInstallation: 'DP'
dependencyCheckPublisher pattern: '**/dependency-check-report.xml'
}
}
stage('Docker Build') {
steps {
script{
withDockerRegistry(credentialsId: '9ea0c4b0-721f-4219-be62-48a976dbeec0') {
sh "docker build -t todoapp:latest -f docker/Dockerfile . "
sh "docker tag todoapp:latest username/todoapp:latest "
}
}
}
}
stage('Docker Push') {
steps {
script{
withDockerRegistry(credentialsId: '9ea0c4b0-721f-4219-be62-48a976dbeec0') {
sh "docker push username/todoapp:latest "
}
}
}
}
stage('trivy') {
steps {
sh " trivy username/todoapp:latest"
}
}
stage('Deploy to Docker') {
steps {
script{
withDockerRegistry(credentialsId: '9ea0c4b0-721f-4219-be62-48a976dbeec0') {
sh "docker run -d --name to-do-app -p 4000:4000 username/todoapp:latest "
}
}
}
}
}
}