-
Notifications
You must be signed in to change notification settings - Fork 2
/
JenkinsfileRelease
81 lines (74 loc) · 4.07 KB
/
JenkinsfileRelease
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
parameters {
string(name: 'testServerUrl', defaultValue: 'https://api-qa.aspose.cloud', description: 'server url')
string(name: 'version', defaultValue: '19.10.0', description: 'version of the package')
string(name: 'StartFromStage', defaultValue: '0', description: '0 based index of stage which will be started')
string(name: 'pypiLogin', description: 'Login for pypi auth')
string(name: 'pypiPass', description: 'Password for pypi auth')
}
node('words-linux') {
try {
stage('0:Merge master to release'){
if (params.StartFromStage.toInteger() < 1) {
checkout([$class: 'GitSCM', branches: [[name: '*/release']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'LocalBranch', localBranch: "**"]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '361885ba-9425-4230-950e-0af201d90547', url: 'https://git.auckland.dynabic.com/words-cloud/words-cloud-python.git']]])
sh "git config user.email 'jenkins.aspose@gmail.com'"
sh "git config user.name 'jenkins'"
sh "git checkout --merge release"
sh "git reset --hard origin/release"
sh "git merge --no-ff --allow-unrelated-histories origin/master"
sh "git diff --name-status"
sh 'git commit -am "Merged master branch to release" || exit 0'
withCredentials([usernamePassword(credentialsId: '361885ba-9425-4230-950e-0af201d90547', passwordVariable: 'gitPass', usernameVariable: 'gitUsername')]) {
sh "git push https://$gitUsername:$gitPass@git.auckland.dynabic.com/words-cloud/words-cloud-python.git release"
}
}
}
} finally {
cleanWs()
}
}
def publishToPypi()
{
try {
stage('6:checkout again'){
if (params.StartFromStage.toInteger() < 7) {
checkout([$class: 'GitSCM', branches: [[name: '*/release']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'LocalBranch', localBranch: "**"]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '361885ba-9425-4230-950e-0af201d90547', url: 'https://git.auckland.dynabic.com/words-cloud/words-cloud-python.git']]])
withCredentials([usernamePassword(credentialsId: '6839cbe8-39fa-40c0-86ce-90706f0bae5d', passwordVariable: 'ClientSecret', usernameVariable: 'ClientId')]) {
sh 'mkdir -p Settings'
sh 'echo "{\\"ClientId\\": \\"$ClientId\\",\\"ClientSecret\\": \\"$ClientSecret\\", \\"BaseUrl\\": \\"$testServerUrl\\"}" > Settings/servercreds.json'
}
}
}
stage('7: upload to PyPi') {
if (params.StartFromStage.toInteger() < 8) {
docker.image('python:3.6').inside('-u root'){
sh "python -m pip install --upgrade setuptools wheel"
sh "python setup.py sdist bdist_wheel"
sh "python -m pip install --upgrade twine python-dateutil"
sh "touch ~/.pypirc"
sh "echo '[distutils] \\n index-servers= \\n\\t pypi \\n [pypi] \\n username = __token__ \\n password = '$pypiPass'' > ~/.pypirc"
sh "python setup.py sdist && twine upload dist/*"
}
}
}
stage('8:add version tag'){
if (params.StartFromStage.toInteger() < 9) {
checkout([$class: 'GitSCM', branches: [[name: '*/release']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'LocalBranch', localBranch: "**"]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '361885ba-9425-4230-950e-0af201d90547', url: 'https://git.auckland.dynabic.com/words-cloud/words-cloud-python.git']]])
sh "git config user.email \"jenkins.aspose@gmail.com\""
sh "git config user.name \"jenkins\""
sh "git tag -a $version -m 'version $version' | exit 0"
withCredentials([usernamePassword(credentialsId: '361885ba-9425-4230-950e-0af201d90547', passwordVariable: 'gitPass', usernameVariable: 'gitUsername')]) {
sh "git push https://$gitUsername:$gitPass@git.auckland.dynabic.com/words-cloud/words-cloud-python.git $version"
}
}
}
} finally {
cleanWs()
}
}
node('words-linux') {
try {
publishToPypi()
} finally {
cleanWs()
}
}