-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
123 lines (122 loc) · 4.24 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
pipeline {
options { disableConcurrentBuilds() }
agent { label 'docker-slave' }
stages {
stage ('Pull repo code from github') {
steps {
checkout scm
}
}
stage('Test syntax verification') {
steps {
sh """ #!/bin/bash
cd syntax
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
python3 -m pytest --pyargs -s ./tests --junitxml="results.xml" --cov=tosca --cov-report xml tests/
cp *.xml $WORKSPACE
"""
junit 'results.xml'
}
}
stage('test workflow verification') {
steps {
sh """ #!/bin/bash
cd workflow
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
python3 -m pip install -U pip setuptools wheel
python3 -m pytest --pyargs -s ./tests --junitxml="results.xml" --cov=pnmlpy --cov-report xml tests/
cp *.xml $WORKSPACE
"""
junit 'results.xml'
}
}
stage('SonarQube analysis workflow'){
environment {
scannerHome = tool 'SonarQubeScanner'
}
steps {
withSonarQubeEnv('SonarCloud') {
sh """ #!/bin/bash
cd "workflow"
${scannerHome}/bin/sonar-scanner
"""
}
}
}
stage('SonarQube analysis syntax'){
environment {
scannerHome = tool 'SonarQubeScanner'
}
steps {
withSonarQubeEnv('SonarCloud') {
sh """ #!/bin/bash
cd "syntax"
${scannerHome}/bin/sonar-scanner
"""
}
}
}
stage('SonarQube analysis api'){
environment {
scannerHome = tool 'SonarQubeScanner'
}
steps {
withSonarQubeEnv('SonarCloud') {
sh """ #!/bin/bash
cd "iacverifier"
${scannerHome}/bin/sonar-scanner
"""
}
}
}
stage('Build docker images') {
when {
allOf {
// Triggered on every tag
expression{tag "*"}
}
}
steps {
sh "cd syntax; docker build -t toscasynverifier -f Dockerfile ."
sh "cd workflow; docker build -t workflowverifier -f Dockerfile ."
sh "cd iacverifier; docker build -t iacverifierapi -f Dockerfile ."
}
}
stage('Push Dockerfile to DockerHub') {
when {
allOf {
// Triggered on every tag
expression{tag "*"}
}
}
steps {
withDockerRegistry(credentialsId: 'jenkins-sodalite.docker_token', url: '') {
sh """#!/bin/bash
docker tag toscasynverifier sodaliteh2020/toscasynverifier:${BUILD_NUMBER}
docker tag toscasynverifier sodaliteh2020/toscasynverifier
docker push sodaliteh2020/toscasynverifier:${BUILD_NUMBER}
docker push sodaliteh2020/toscasynverifier
docker tag workflowverifier sodaliteh2020/workflowverifier:${BUILD_NUMBER}
docker tag workflowverifier sodaliteh2020/workflowverifier
docker push sodaliteh2020/workflowverifier:${BUILD_NUMBER}
docker push sodaliteh2020/workflowverifier
docker tag iacverifierapi sodaliteh2020/iacverifierapi:${BUILD_NUMBER}
docker tag iacverifierapi sodaliteh2020/iacverifierapi
docker push sodaliteh2020/iacverifierapi:${BUILD_NUMBER}
docker push sodaliteh2020/iacverifierapi
"""
}
}
}
}
post {
failure {
slackSend (color: '#FF0000', message: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
fixed {
slackSend (color: '#6d3be3', message: "FIXED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
}
}