-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
115 lines (101 loc) · 4.13 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
#!/usr/bin/env groovy
def user = 'artsalliancemedia'
def repo = 'thunderstorm-library'
node('aam-identity-prodcd') {
properties([
[
$class: 'HudsonNotificationProperty',
endpoints: [[
event: 'all',
format: 'JSON',
loglines: 0,
protocol: 'HTTP',
timeout: 30000,
url: 'https://webhooks.gitter.im/e/953b1e47e601cbf09ff8']]
],
[
$class: 'GithubProjectProperty',
displayName: 'TS Lib',
projectUrlStr: 'https://github.com/artsalliancemedia/thunderstorm-library/'
]
])
def COMPOSE_PROJECT_NAME = getDockerComposeProject()
stage('Checkout') {
checkout scm
}
try {
def registry = '886366864302.dkr.ecr.eu-west-1.amazonaws.com'
// CODACY_PROJECT_TS_LIB_TOKEN is a global set in jenkins
stage('Test') {
withEnv([
"REGISTRY=${registry}"
]) {
sh 'docker-compose up -d'
sh 'sleep 5'
parallel 'python36': {
withEnv(["COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}36"]) {
sh "docker-compose run -e CODACY_PROJECT_TOKEN=${env.CODACY_PROJECT_TS_LIB_TOKEN} -e PYTHON_VERSION=36 python36 make install test codacy"
junit 'results-36.xml'
}
}, 'python37': {
withEnv(["COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}37"]) {
sh "docker-compose run -e CODACY_PROJECT_TOKEN=${env.CODACY_PROJECT_TS_LIB_TOKEN} -e PYTHON_VERSION=37 python37 make install test codacy"
junit 'results-37.xml'
}
}, 'compatibility-marshmallow-2.X': {
withEnv(["COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}36compat"]) {
sh "docker-compose run -e CODACY_PROJECT_TOKEN=${env.CODACY_PROJECT_TS_LIB_TOKEN} -e PYTHON_VERSION=36 -e COMPAT=compat -e DB_NAME=test_auth_lib_py36_compat python36 make install compat test codacy"
junit 'results-36compat.xml'
}
}
sh 'docker-compose down'
}
}
// determine if release should be pushed: the most recent commit must contain string "[release]"
def is_release = sh (script: 'git log --oneline --no-merges -1 | grep -q \'\\[release\\]\'', returnStatus: true)
// master branch builds are pushed to Github
if (env.BRANCH_NAME == 'master') {
stage('Create Github Release') {
if (is_release == 0) {
// GITHUB_TOKEN is a global set in jenkins
withEnv([
"GITHUB_TOKEN=${env.GITHUB_TOKEN}",
]) {
// create distribution
sh 'sudo chmod -R 777 thunderstorm_library.egg-info/'
sh "make dist"
sh "./script/release.sh '${user}' '${repo}'"
}
} else {
echo 'No [release] commit -- skipping'
}
}
stage("Changelog") {
description = gitChangelog returnType: 'STRING',
gitHub: [api: 'https://api.github.com/repos/artsalliancemedia/thunderstorm-library', issuePattern: '', token: env.GITHUB_TOKEN],
from: [type: 'REF', value: 'master'],
to: [type: 'REF', value: env.BRANCH_NAME],
template: prTemplate()
echo "### Changelog ###"
echo "${description}"
echo "### Changelog ###"
}
}
} catch (err) {
junit 'results-*.xml'
error 'Thunderstorm library build failed ${err}'
} finally {
sh 'docker-compose down'
}
}
def getDockerComposeProject() {
return sh(
script: "basename `pwd` | sed 's/^[^a-zA-Z0-9]*//g'",
returnStdout: true
).trim()
}
def prTemplate() {
def template = readFile 'CHANGELOG.md'
// don't forget to trim or you'll get a newline in the string
return template.trim()
}