-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJenkinsfile
More file actions
67 lines (65 loc) · 2.02 KB
/
Jenkinsfile
File metadata and controls
67 lines (65 loc) · 2.02 KB
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
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Test python app') {
agent {
docker { image 'python:3.8.8-slim-buster' }
}
steps {
script {
dir('app') {
sh '''
python -m venv env
env/bin/pip install -r requirements-dev.txt
env/bin/pytest . --junit-xml=pytest_junit.xml
'''
}
}
}
post {
always {
junit testResults: '**/*pytest_junit.xml'
}
}
}
stage('Build & test docker image') {
steps {
script {
appImage = docker.build('greeter:latest')
sh label: 'Install dgoss', script: '''
curl -s -L https://github.com/aelsabbahy/goss/releases/latest/download/goss-linux-amd64 -o goss
curl -s -L https://github.com/aelsabbahy/goss/releases/latest/download/dgoss -o dgoss
chmod +rx *goss
'''
withEnv(["GOSS_OPTS=-f junit", 'GOSS_PATH=./goss']) {
sh label: 'run image tests', script: './dgoss run greeter:latest > goss_junit.xml'
}
}
}
post {
always {
junit testResults: '**/*goss_junit.xml'
}
}
}
stage('Deploy') {
steps {
script {
docker.withRegistry('https://registry.example.com', 'credentials-id') {
appImage.push('latest')
}
}
}
}
}
post {
cleanup {
script { cleanWs() }
}
}
}