-
Notifications
You must be signed in to change notification settings - Fork 1
/
release.groovy
67 lines (65 loc) · 2.84 KB
/
release.groovy
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
/*
* (C) Copyright 2021 Nuxeo (http://nuxeo.com/).
* This is unpublished proprietary source code of Nuxeo SA. All rights reserved.
* Notice of copyright on this source code does not indicate publication.
*
* Contributors:
* Julien Carsique <[email protected]>
*/
void setGitHubBuildStatus(String context) {
step([
$class : 'GitHubCommitStatusSetter',
reposSource : [$class: 'ManuallyEnteredRepositorySource', url: 'https://github.com/nuxeo/nuxeo-insight-client'],
contextSource: [$class: 'ManuallyEnteredCommitContextSource', context: context],
errorHandlers: [[$class: 'ShallowAnyErrorHandler']]
])
}
pipeline {
agent {
label "jenkins-ai-nuxeo11"
}
parameters {
string(name: 'BRANCH', defaultValue: 'master', description: 'Branch to release from.')
string(name: 'VERSION', description: '''The version to release.
Leave it unset to use the version of the Maven POM.
The version must match "X.Y.Z[-PRERELEASE][+BUILD]"''')
choice(name: 'INCREMENT', choices: ['patch', 'minor', 'major', 'release'], description: '''Semantic versioning increment.
The "release" increment mode removes any PRERELEASE or BUILD parts (see VERSION).''')
booleanParam(name: 'DRY_RUN', defaultValue: true, description: 'Dry run')
}
options {
disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr: '10', artifactNumToKeepStr: '3'))
timeout(time: 1, unit: 'HOURS')
}
stages {
stage('Release') {
steps {
setGitHubBuildStatus('release')
container('platform11') {
withEnv(["BRANCH=${params.BRANCH}", "VERSION=${params.VERSION}", "INCREMENT=${params.INCREMENT}",
"DRY_RUN=${params.DRY_RUN}"]) {
script {
sh './tools/release.sh'
sh 'chmod +r VERSION || true'
if ("$DRY_RUN" != 'true') {
def releaseProps = readProperties file: 'release.properties'
def jobName = '/nuxeo/nuxeo-insight-client/v' + releaseProps['RELEASE_VERSION']
if (!Jenkins.instance.getItemByFullName(jobName)) {
build job: '/nuxeo/nuxeo-insight-client/', propagate: false, wait: true
}
build job: jobName, propagate: false, wait: false
}
}
}
}
}
post {
always {
setGitHubBuildStatus('release')
archiveArtifacts artifacts: 'release.properties', allowEmptyArchive: true
}
}
}
}
}