forked from PegaSysEng/pantheon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.release
61 lines (55 loc) · 2.58 KB
/
Jenkinsfile.release
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
void tryAddKnownHost(String hostUrl){
// ssh-keygen -F ${hostUrl} will fail (in bash that means status code != 0) if ${hostUrl} is not yet a known host
def statusCode = sh script:"ssh-keygen -F ${hostUrl}", returnStatus:true
if(statusCode != 0){
sh "mkdir -p ~/.ssh"
sh "ssh-keyscan ${hostUrl} >> ~/.ssh/known_hosts"
}
}
pipeline {
agent {
docker { image 'pegasyseng/pantheon-build:0.0.2' }
}
parameters {
string(name: 'BRANCH_NAME', defaultValue: 'master', description: '[MANDATORY] The name of the branch to create the release from')
string(name: 'RELEASE_VERSION', defaultValue: '', description: '[OPTIONAL] When empty: defaults to the current project version')
string(name: 'NEXT_VERSION', defaultValue: '', description: '[OPTIONAL] When empty: defaults to next patch version after current project version')
}
stages {
stage('Release') {
steps {
sshagent(
credentials: ['pegasys-admin-github-ssh-private-key']
) {
withCredentials([
usernamePassword(
credentialsId: 'pegasys-bintray',
usernameVariable: 'BINTRAY_USER',
passwordVariable: 'BINTRAY_KEY'
)
]) {
withEnv([
'GIT_COMMITTER_NAME="PegaSys Admin"',
'GIT_COMMITTER_EMAIL="pegasys.manager@gmail.com"',
'GIT_AUTHOR_NAME="PegaSys Admin"',
'GIT_AUTHOR_EMAIL="pegasys.manager@gmail.com"'
]) {
tryAddKnownHost('github.com')
script{
releaseVersion = ''
if( params.RELEASE_VERSION?.trim() ){
releaseVersion = "-Prelease.releaseVersion=${params.RELEASE_VERSION}"
}
nextVersion = ''
if( params.NEXT_VERSION?.trim() ){
nextVersion = "-Prelease.newVersion=${params.NEXT_VERSION}"
}
}
sh "./gradlew release -Prelease.useAutomaticVersion=true -Prelease.branch=${params.BRANCH_NAME} ${releaseVersion} ${nextVersion}"
}
}
}
}
}
}
}