-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathJenkinsfile
112 lines (104 loc) · 2.92 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
pipeline {
agent {
docker {
image 'python:3.6.2'
}
}
options {
timeout(time: 10, unit: 'MINUTES')
ansiColor('xterm')
}
stages {
stage('Before Install') {
steps {
sh """
python -m venv venv
. venv/bin/activate
pip install --upgrade pip
pip install --upgrade setuptools
pip install --upgrade pytest
pip --version
"""
}
}
stage('Install') {
steps {
sh """
. venv/bin/activate
python setup.py -q install
python setup.py sdist
pip install -r requirements/dev.txt
"""
}
}
stage('Test') {
steps {
sh """
. venv/bin/activate
py.test --junitxml=pytest-report.xml --cov-report xml --cov --cov-report term-missing
"""
}
post {
always {
junit 'pytest-report.xml'
}
}
}
stage('Coverage') {
steps {
sh """
. venv/bin/activate
coverage xml -i
"""
}
post {
always {
cobertura autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: 'coverage.xml', conditionalCoverageTargets: '70, 0, 0', enableNewApi: true, failUnhealthy: false, failUnstable: false, lineCoverageTargets: '80, 0, 0', maxNumberOfBuilds: 0, methodCoverageTargets: '80, 0, 0', onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false
}
}
}
stage('Docs') {
steps {
sh """
. venv/bin/activate
invoke docs
"""
}
}
stage('Deploy Docs (Github)') {
when { branch 'master' }
environment {
GITHUB = credentials('github-halkeye')
DEPLOY_DIRECTORY = 'docs/build'
DEPLOY_BRANCH = 'gh-pages'
HOME = "${env.WORKSPACE}"
}
steps {
sh 'git config --global user.email "[email protected]"'
sh 'git config --global user.name "Jenkins"'
sh 'git config --global push.default simple'
sh "git clone --single-branch --branch ${env.DEPLOY_BRANCH} ${env.GIT_URL.replace("https://", "https://${GITHUB_USR}:${GITHUB_PSW}@")} ${env.DEPLOY_BRANCH}"
sh "rm -rf ${env.DEPLOY_BRANCH}/*"
sh "cp -a ${env.DEPLOY_DIRECTORY}/* ${env.DEPLOY_BRANCH}/"
dir(env.DEPLOY_BRANCH) {
sh 'git config --global user.email "[email protected]"'
sh 'git config --global user.name "Jenkins"'
sh 'git config --global push.default simple'
sh 'git add --all && git commit -m "Publishing to gh-pages" --allow-empty'
sh "git push"
}
sh "rm -rf ${env.DEPLOY_BRANCH}"
}
}
}
post {
failure {
emailext(
attachLog: true,
recipientProviders: [developers()],
body: "Build failed (see ${env.BUILD_URL})",
subject: "[JENKINS] ${env.JOB_NAME} failed",
)
}
}
}