-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
66 lines (57 loc) · 1.68 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
def imageName="192.168.44.44:8082/docker_registry/backend"
def dockerTag=""
def dockerRegistry="https://192.168.44.44:8082"
def registryCredentials="artifactory"
pipeline {
agent {
label 'agent'
}
environment {
PIP_BREAK_SYSTEM_PACKAGES = 1
scannerHome = tool 'SonarQube'
}
stages {
stage('Pobierz kod z repo') {
steps {
checkout scm
}
}
stage('Wykonaj testy') {
steps {
sh "pip3 install -r requirements.txt"
sh "python3 -m pytest --cov=. --cov-report xml:test-results/coverage.xml --junitxml=test-results/pytest-report.xml"
}
}
stage('Anzaliza Sonarqube') {
steps {
withSonarQubeEnv('SonarQube') {
sh "${scannerHome}/bin/sonar-scanner"
}
}
}
stage('Budujemy kontener z aplikacja') {
steps {
script {
dockerTag = "RC-${env.BUILD_ID}"
applicationImage = docker.build("$imageName:$dockerTag")
}
}
}
stage ('Wypychamy image do artifactory do docker registry') {
steps {
script {
docker.withRegistry("$dockerRegistry", "$registryCredentials") {
applicationImage.push()
applicationImage.push('latest')
}
}
}
}
}
post {
always {
junit testResults: "test-results/*.xml"
cleanWs()
}
}
}