forked from nuxeo/nuxeo-ai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.groovy
100 lines (98 loc) · 4.08 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* (C) Copyright 2020 Nuxeo (http://nuxeo.com/) and others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Contributors:
* jcarsique
*/
void setGitHubBuildStatus(String context) {
step([
$class : 'GitHubCommitStatusSetter',
reposSource : [$class: 'ManuallyEnteredRepositorySource', url: 'https://github.com/nuxeo/nuxeo-ai'],
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'
if ("$DRY_RUN" != 'true') {
def releaseProps = readProperties file: 'release.properties'
def jobName = '/nuxeo/nuxeo-ai/v' + releaseProps['RELEASE_VERSION']
while (!Jenkins.instance.getItemByFullName(jobName)) {
build job: '/nuxeo/nuxeo-ai/', propagate: false, wait: false
// can't wait for non-job item
sleep time: 1, unit: 'MINUTES'
}
build job: jobName, propagate: false, wait: false
}
}
}
}
}
post {
always {
setGitHubBuildStatus('release')
archiveArtifacts artifacts: 'release.properties, charts/*/templates/release.yaml', allowEmptyArchive: true
}
}
}
stage('Update downstream repos') {
steps {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
setGitHubBuildStatus('post-release')
container('platform11') {
withEnv(["DRY_RUN=${params.DRY_RUN}"]) {
script {
def nextVersion = readProperties(file: 'release.properties')['NEXT_VERSION'].trim()
sh """#!/bin/bash -xe
./tools/updatebot.sh ${nextVersion}
"""
}
}
}
}
}
post {
always {
setGitHubBuildStatus('post-release')
}
}
}
}
}