-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
113 lines (95 loc) · 3.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
#!/usr/bin/env groovy
pipeline {
agent {
docker { image 'gcr.io/ascalon-dev/jenkins-tools:0.1.17' }
}
options {
disableConcurrentBuilds()
gitLabConnection('GitLab')
gitlabBuilds(builds: ['deploy', 'report'])
}
environment {
PYPI_REPO_URL = "http://nexus.office.resolvity.com:8081/repository/pypi-resolvity/"
NEXUS_CREDENTIALS = credentials('9c5404f1-0abc-470b-a910-514f8250e529')
NL = sh(
script: "echo -n '\n'",
returnStdout: true
)
GIT_COMMITTER_NAME = sh(
script: "git --no-pager show -s --format=%cn ${env.GIT_COMMIT}",
returnStdout: true
).trim()
GIT_COMMITTER_EMAIL = sh(
script: "git --no-pager show -s --format=%ce ${env.GIT_COMMIT}",
returnStdout: true
).trim()
GIT_COMMITTER_DATE = sh(
script: "git --no-pager show -s --format=%cd ${env.GIT_COMMIT}",
returnStdout: true
).trim()
}
stages {
stage('release') {
steps {
sh("python setup.py sdist")
// sh(" VERSION="$(grep -Eo '[0-9.]{6,7}' setup.py | head -1)" ")
VERSION = sh(grep -Eo '[0-9.]{6,7}' setup.py | head -1)
// sh("gh release create $("$(grep -Eo '[0-9.]{6,7}' setup.py | head -1)")")
sh("gh release create ${VERSION}")
withCredentials([usernamePassword(credentialsId: 'devops-voicegain', passwordVariable: '?????DOCK1_PASSWORD', usernameVariable: 'DOCK1_USERNAME')]){
sh("python -m twine upload dist/voicegain-speech-${VERSION}.tar.gz")
}}
post {
success {
updateGitlabCommitStatus name: 'deploy', state: 'success'
}
failure {
updateGitlabCommitStatus name: 'deploy', state: 'failed'
}
}
}
post {
success {
updateGitlabCommitStatus name: 'web-doc', state: 'success'
}
failure {
updateGitlabCommitStatus name: 'web-doc', state: 'failed'
}
}
}
stage('report') {
steps {
script {
PACKAGE_INFO = sh(
script: "get_python_package_version",
returnStdout: true
).trim()
}
}
post {
success {
updateGitlabCommitStatus name: 'report', state: 'success'
}
failure {
updateGitlabCommitStatus name: 'report', state: 'failed'
}
}
}
}
post {
success {
slackSend(
channel: '#jenkins',
color: '#00ff00',
message: "*SUCCESS!* @here${NL}*Repo:* ${env.GIT_URL}${NL}*Branch:* ${env.GIT_BRANCH}${NL}*Commit:* ${env.GIT_COMMIT}${NL}*Job:* ${env.BUILD_URL}${NL}${NL}*Details:* ${NL}Deploy python package ${PACKAGE_INFO} to ${PYPI_REPO_URL}${NL}:smiley::thumbsup: *\"${GIT_COMMITTER_NAME}\"* at ${GIT_COMMITTER_DATE}"
)
}
failure {
slackSend(
channel: '#jenkins',
color: '#ff0000',
message: "*FAILED!* @here${NL}*Repo:* ${env.GIT_URL}${NL}*Branch:* ${env.GIT_BRANCH}${NL}*Commit:* ${env.GIT_COMMIT}${NL}*Job:* ${env.BUILD_URL}${NL}:rage::point_right: *\"${GIT_COMMITTER_NAME}\"* at ${GIT_COMMITTER_DATE}"
)
}
}
}