-
Notifications
You must be signed in to change notification settings - Fork 4
/
Jenkinsfile
64 lines (57 loc) · 2.29 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
pipeline {
agent any
options {
buildDiscarder(logRotator(numToKeepStr: '30', artifactNumToKeepStr: '20'))
}
parameters {
string(name: 'engineListUrl',
description: 'Engine to use for build',
defaultValue: 'https://product.ivyteam.io')
}
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 'info@ivyteam.ch'"
sh "git checkout -b ${targetBranch}"
setupGPGEnvironment()
withCredentials([string(credentialsId: 'gpg.password', variable: 'GPG_PWD')]) {
def dryRun = isReleaseBranch() ? '' : '-DdryRun=true'
def args = "-PossrhDeploy -Divy.engine.list.url=${params.engineListUrl} -Dgpg.project-build.password='${env.GPG_PWD}'"+
" -Dgithub.site.skip=false";
maven cmd: dryRun + ' -Darguments="' + args + '" -DpushChanges=false -DlocalCheckout=true 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}"
}
// publish site from 'mvn release' run
maven cmd: "site:stage scm-publish:publish-scm"
}
}
}
}
archiveArtifacts '**/target/*.jar'
}
}
}
}
def isReleaseBranch() {
return env.BRANCH_NAME.startsWith('release/')
}
def setupGPGEnvironment() {
withCredentials([file(credentialsId: 'gpg.keystore', variable: 'GPG_FILE')]) {
sh "gpg --batch --import ${env.GPG_FILE}"
}
}