-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile.old
81 lines (66 loc) · 2.46 KB
/
Jenkinsfile.old
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
#!groovy
node {
def version
def webAppTarget = "xxx"
def sourceBranch = "master"
def releaseBranch = "feature3"
def nexusBaseRepoUrl = "http://xxx"
def repositoryUrl = "http://xxx"
def gitCredentialsId = "xxx"
def nexusRepositoryId = "xxx"
def configFileId = "xxx"
def mvnHome = tool 'M3'
def updateQAVersion = {
def split = version.split('\\.')
//always remove "-SNAPSHOT"
split[2] = split[2].split('-SNAPSHOT')[0]
//increment the middle number of version by 1
split[1] = Integer.parseInt(split[1]) + 1
//reset the last number to 0
split[2] = 0
version = split.join('.')
}
//FIXME: use SSH-Agent
//FIXME: use SSH-Agent
sh "git config --replace-all credential.helper cache"
sh "git config --global --replace-all user.email [email protected] git config --global --replace-all user.name cmguedmini"
configFileProvider([configFile(fileId: "${configFileId}", variable: "MAVEN_SETTINGS")]) {
stage('Clean') {
deleteDir()
}
dir('qa') {
stage('Checkout QA') {
echo 'Load from GIT'
checkout scm
}
stage('Increment QA version') {
version = sh(returnStdout: true, script: "${mvnHome}/bin/mvn -q -N org.codehaus.mojo:exec-maven-plugin:1.3.1:exec -Dexec.executable='echo' -Dexec.args='\${project.version}'").toString().trim()
echo 'Old Version:'
echo version
updateQAVersion()
echo 'New Version:'
echo version
}
stage('Set new QA version') {
echo 'Clean Maven'
sh "${mvnHome}/bin/mvn -B clean -s '$MAVEN_SETTINGS'"
echo 'Set new version'
sh "${mvnHome}/bin/mvn -B versions:set -DnewVersion=${version}"
}
stage('QA Build') {
echo 'Execute maven build'
sh "${mvnHome}/bin/mvn -B install -s '$MAVEN_SETTINGS'"
}
stage('Push new QA version') {
echo 'Commit and push branch'
sh "git commit -am \"New release candidate ${version}\""
sh "git push origin ${releaseBranch}"
}
stage('Push new tag') {
echo 'Tag and push'
sh "git tag -a ${version} -m 'release tag'"
sh "git push origin ${version}"
}
}
}
}