-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
61 lines (59 loc) · 1.63 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
def imageName="192.168.44.44:8082/docker-local/backend"
def dockerRegistry="https://192.168.44.44:8082"
def registryCredentials="artifactory"
def dockerTag=""
pipeline {
agent {
label 'agent'
}
environment {
scannerHome = tool 'SonarQube'
}
stages {
stage('Clone Backend Repository') {
steps {
checkout scm
}
}
stage('Unit Tests') {
steps {
sh '''pip3 install -r requirements.txt
python3 -m pytest --cov=. --cov-report xml:test-results/coverage.xml --junitxml=test-results/pytest-report.xml'''
}
}
stage('SonarQube') {
steps {
withSonarQubeEnv('SonarQube') {
sh "${scannerHome}/bin/sonar-scanner"
}
timeout(1) {
waitForQualityGate true
}
}
}
stage('Build Application') {
steps {
script {
dockerTag = "RC-${BUILD_ID}"
applicationImage = docker.build("$imageName:$dockerTag", ".")
}
}
}
stage('Deploy Image') {
steps {
withDockerRegistry(credentialsId: "${registryCredentials}", url: "${dockerRegistry}") {
script {
applicationImage.push()
applicationImage.push("latest")
}
}
}
}
}
post {
always {
junit testResults: 'test-results/*.xml'
cleanWs()
}
}
}