-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
93 lines (85 loc) · 3.15 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
pipeline {
agent {
label 'utility'
}
environment{
SLACK_CHANNEL = '#platform-engineering-ci'
PRIVATE_PYPI = "https://devpi-sac0.backblaze.com/bz/uploads"
}
options {
disableConcurrentBuilds()
timeout(time: 10, unit: 'MINUTES')
}
stages {
stage('Notify Build') {
steps {
script {
commit = sh(script: "git log -1 --pretty=format:'%an: %s'", returnStdout: true).trim()
hash = sh(script: "git log -1 --pretty=%h", returnStdout: true).trim()
slackSend(
color: "#6ECADC", // blue
channel: env.SLACK_CHANNEL,
message: "Started job: *${currentBuild.fullDisplayName}* \nNode: ${env.NODE_NAME} \nExecutor: ${env.EXECUTOR_NUMBER} \nURL: <${env.BUILD_URL}|${env.BUILD_DISPLAY_NAME}> \n Commit: [<https://github.com/Backblaze/migration_dash/commit/${env.GIT_COMMIT}|${hash}>] ${commit}"
)
}
}
}
stage('Virtual Environment') {
environment {
PYTHON = '/usr/local/bin/python3.9'
}
steps {
sh "./create_venv.sh"
}
}
stage('Lint') {
steps {
sh 'venv/bin/black --check .'
sh 'venv/bin/pyre check'
}
}
stage('Publish PyPI Artifact') {
when {
branch "main"
}
steps {
withCredentials([usernamePassword(
credentialsId: 'devpi_bz',
usernameVariable: 'TWINE_USERNAME',
passwordVariable: 'TWINE_PASSWORD'
)]) {
sh '''
git clean -qfd # we clean so that we don't flag our build as dirty.
./pypi_publish.sh "${PRIVATE_PYPI}"
'''
}
}
}
}
post {
always {
jiraSendBuildInfo site: 'backblaze.atlassian.net'
}
failure {
slackSend(
color: "#E01563", // red
channel: env.SLACK_CHANNEL,
message: "Build failed: *${currentBuild.fullDisplayName}* \nURL: <${env.BUILD_URL}|${env.BUILD_DISPLAY_NAME}> \nDuration: ${currentBuild.durationString.replace(' and counting', '')}"
)
}
aborted {
slackSend(
color: "#FFC300", // yellow
channel: env.SLACK_CHANNEL,
message: "Build aborted: *${currentBuild.fullDisplayName}* \nURL: <${env.BUILD_URL}|${env.BUILD_DISPLAY_NAME}> \nDuration: ${currentBuild.durationString.replace(' and counting', '')}"
)
}
success {
slackSend(
color: "#3EB991", // green
channel: env.SLACK_CHANNEL,
message: "Build succeeded: *${currentBuild.fullDisplayName}* \nURL: <${env.BUILD_URL}|${env.BUILD_DISPLAY_NAME}> \nDuration: ${currentBuild.durationString.replace(' and counting', '')}"
)
}
}
}