forked from kiali/kiali.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
80 lines (74 loc) · 2.59 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
/*
* This pipeline supports only `minor` releases. Don't run it on `major`, `patch`,
* `snapshot`, nor `edge` releases.
*
* The Jenkins job should be configured with the following properties:
*
* - Disable concurrent builds
* - Parameters (all must be trimmed; all are strings):
* - SITE_REPO
* defaultValue: kiali/kiali.io
* description: The GitHub repo of the website sources, in owner/repo format.
* - SITE_RELEASING_BRANCH
* defaultValue: refs/heads/master
* description: Branch of the website to checkout and run the release
*/
def bumpVersion(String versionType, String currentVersion) {
def split = currentVersion.split('\\.')
switch (versionType){
case "patch":
split[2]=1+Integer.parseInt(split[2])
break
case "minor":
split[1]=1+Integer.parseInt(split[1])
split[2]=0
break;
case "major":
split[0]=1+Integer.parseInt(split[0])
split[1]=0
split[2]=0
break;
}
return split.join('.')
}
node('kiali-build && fedora') {
def siteMakefile = 'Makefile.site.jenkins'
def siteGitUri = "[email protected]:${params.SITE_REPO}.git"
def mainBranch = 'master'
try {
stage('Checkout code') {
checkout([
$class: 'GitSCM',
branches: [[name: params.SITE_RELEASING_BRANCH]],
doGenerateSubmoduleConfigurations: false,
extensions: [
[$class: 'LocalBranch', localBranch: '**']
],
submoduleCfg: [],
userRemoteConfigs: [[
credentialsId: 'kiali-bot-gh-ssh',
url: siteGitUri]]
])
sh "git config user.email '[email protected]'"
sh "git config user.name 'kiali-bot'"
}
stage('Release website') {
withCredentials([string(credentialsId: 'kiali-bot-gh-token', variable: 'GH_TOKEN')]) {
sshagent(['kiali-bot-gh-ssh']) {
def releasingVersion = sh(
returnStdout: true,
script: "sed -rn 's/^VERSION \\?= v(.*)/\\1/p' Makefile").trim()
def nextVersion = bumpVersion("minor", releasingVersion)
echo "Will build version: ${releasingVersion}"
sh "./scripts/build-archive.sh v${releasingVersion}"
echo "Prepare for next version: ${nextVersion}"
sh "sed -i -r 's/^VERSION \\?= v.*/VERSION \\?= v${nextVersion}/' Makefile"
sh "git add -A && git commit -m \"Release v${releasingVersion}\""
sh "git push origin HEAD:${mainBranch} && git push origin HEAD:refs/tags/v${releasingVersion}"
}
}
}
} finally {
cleanWs()
}
}