-
Notifications
You must be signed in to change notification settings - Fork 3
/
Jenkinsfile
124 lines (121 loc) · 4.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
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
124
node {
stage('Git Checkout') {
sh 'if [ -d ".git" ]; then git clean -ffdx; fi'
checkout scm
if (env.BRANCH_NAME.startsWith('release/')) {
sh 'sed -i "s/_BUILD//g" src/bromine/_version.py'
} else {
sh 'sed -i "s/_BUILD/.dev${BUILD_NUMBER}/g" src/bromine/_version.py'
}
sh 'sed -i "s/COMMIT/$(git log -n 1 --pretty=format:\"%h\")/g" src/bromine/_version.py'
}
stage('Bdist Wheel') {
docker.image('python:3.8').inside('-v /etc/passwd:/etc/passwd') {
sh """
python3 -m venv /tmp/venv
. /tmp/venv/bin/activate
pip install -U --no-cache-dir -r requirements/build.txt
make clean
python setup.py bdist_wheel --universal
"""
}
}
/*stage('GPG Sign') {
withCredentials([string(credentialsId: 'jenkins_gpg_0780E4BA_pwd', variable: 'PASSWORD')]) {
sh 'gpg --detach-sign -a --batch --passphrase "$PASSWORD" dist/bromine-*.whl'
}
}
stage('QA - Verify Signature') {
sh """
gpg --dearmor <pypi_gpg_sign.pub.asc >pypi_gpg_sign.pub.pgp
gpg --no-default-keyring --keyring ./pypi_gpg_sign.pub.pgp --verify dist/bromine-*.whl.asc
"""
}*/
stage('QA - Test') {
parallel py38: {
docker.image('python:3.8').inside('-v /etc/passwd:/etc/passwd') {
stage('Tox -e py38') {
sh """
python3 -m venv /tmp/venv
. /tmp/venv/bin/activate
pip install --no-cache-dir -r requirements/qa.txt
tox -e py38 --installpkg dist/bromine-*.whl --workdir /tmp/venv38
"""
}
}
}, py37: {
docker.image('python:3.7').inside('-v /etc/passwd:/etc/passwd') {
stage('Tox -e py37') {
sh """
python3 -m venv /tmp/venv
. /tmp/venv/bin/activate
pip install --no-cache-dir -r requirements/qa.txt
tox -e py37 --installpkg dist/bromine-*.whl --workdir /tmp/venv37
"""
}
}
}, py36: {
docker.image('python:3.6').inside('-v /etc/passwd:/etc/passwd') {
stage('Tox -e py36') {
sh """
python3 -m venv /tmp/venv
. /tmp/venv/bin/activate
pip install --no-cache-dir -r requirements/qa.txt
tox -e py36 --installpkg dist/bromine-*.whl --workdir /tmp/venv36
"""
}
}
}
}
stage('QA - Coverage') {
docker.image('python:3.8').inside('-v /etc/passwd:/etc/passwd') {
sh """
python3 -m venv /tmp/venv
. /tmp/venv/bin/activate
pip install --no-cache-dir -r requirements/qa.txt
rm -f .coverage
coverage combine .coverage_*
coverage report -m
"""
}
}
stage('QA - Lint') {
docker.image('python:3.8').inside('-v /etc/passwd:/etc/passwd') {
sh """
python3 -m venv /tmp/venv
. /tmp/venv/bin/activate
pip install --no-cache-dir -r requirements/qa.txt -r requirements/bromine.txt
make lint
"""
}
}
if (env.BRANCH_NAME.startsWith("development/") || env.BRANCH_NAME.startsWith("release/")) {
stage('Publish to Private Nexus') {
docker.image('python:3.8').inside('-v /etc/passwd:/etc/passwd') {
withCredentials([
usernamePassword(credentialsId: 'nexus-id',
usernameVariable: 'USERNAME',
passwordVariable: 'PASSWORD'),
string(credentialsId: 'nexus_url', variable: 'NEXUS_URL')
]) {
sh """
python3 -m venv /tmp/venv
. /tmp/venv/bin/activate
pip install --no-cache-dir -r requirements/pypi.txt
twine upload --repository-url ${NEXUS_URL}/bromine/ -u $USERNAME -p $PASSWORD dist/bromine-*.whl
"""
}
}
}
if (env.BRANCH_NAME.startsWith("release/")) {
stage('Git Tag') {
def built_version = sh(returnStdout: true,
script: "ls -1 dist/bromine-*.whl | cut -d '-' -f 2").trim()
sh """
git tag ${built_version}
git push origin ${built_version}
"""
}
}
}
}