-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
60 lines (54 loc) · 2.41 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
pipeline {
agent any
options {
buildDiscarder(logRotator(numToKeepStr: '30', artifactNumToKeepStr: '20'))
}
parameters {
string(name: 'engineSource', defaultValue: 'https://product.ivyteam.io', description: 'Engine page url')
}
stages {
stage('build') {
when {
expression { isReleaseBranch() }
}
steps {
script {
docker.build('maven').inside {
def targetBranch = "${env.BRANCH_NAME}-${env.BUILD_NUMBER}"
sh "git config --global user.name 'ivy-team'"
sh "git config --global user.email '[email protected]'"
sh "git checkout -b ${targetBranch}"
withCredentials([string(credentialsId: 'gpg.password.axonivy', variable: 'GPG_PWD'), file(credentialsId: 'gpg.keystore.axonivy', variable: 'GPG_FILE')]) {
sh "gpg --batch --import ${env.GPG_FILE}"
def dryRun = isReleaseBranch() ? '' : '-DdryRun=true'
def reactorArgs = "-Dmaven.test.skip=true " +
"-Dengine.page.url=${params.engineSource} " +
"-Dskip.gpg=false " +
"-Dgpg.passphrase='${env.GPG_PWD}'"
def releaseArgs = "-DpomFileName=pom.test.xml " +
"-DautoVersionSubmodules=true " +
"-DpushChanges=false " +
"-DlocalCheckout=true"
maven cmd: '--batch-mode -f pom.test.xml ' + dryRun + ' -Darguments="' + reactorArgs + '" ' + releaseArgs + ' release:prepare release:perform'
}
withEnv(['GIT_SSH_COMMAND=ssh -o StrictHostKeyChecking=no']) {
sshagent(credentials: ['github-axonivy']) {
sh "git push origin --tags"
sh "git push -u origin ${targetBranch}"
def message = "Prepare for next development cycle (${env.BRANCH_NAME})"
withCredentials([file(credentialsId: 'github-ivyteam-token-repo-manager', variable: 'tokenFile')]) {
sh "gh auth login --with-token < ${tokenFile}"
sh "gh pr create --title '${message}' --body '${message}' --head ${targetBranch} --base ${env.BRANCH_NAME}"
}
}
}
}
}
archiveArtifacts '**/target/*.jar'
}
}
}
}
def isReleaseBranch() {
return env.BRANCH_NAME.startsWith('release/')
}