-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
110 lines (106 loc) · 3.51 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
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
101
102
103
104
105
106
107
108
109
110
/*
* (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']]
])
}
String getMavenArgs() {
def args = '-V -B -PJX'
if (env.TAG_NAME || env.BRANCH_NAME ==~ 'master.*') {
args += ' deploy -P-nexus'
if (env.TAG_NAME) {
args += ' -Prelease -DskipTests'
}
} else if (env.BRANCH_NAME ==~ 'sprint-.*') {
args += ' deploy -Pnexus'
} else {
args += ' package'
}
return args
}
String getVersion() {
String version = readMavenPom().getVersion()
version = env.TAG_NAME ? version : version + "-" + env.BRANCH_NAME.replace('/', '-')
assert version ==~ /[0-9A-Za-z\-._]*/
return version
}
pipeline {
agent {
label "jenkins-ai-nuxeo11"
}
options {
disableConcurrentBuilds()
buildDiscarder(logRotator(daysToKeepStr: '60', numToKeepStr: '60', artifactNumToKeepStr: '5'))
timeout(time: 1, unit: 'HOURS')
}
environment {
VERSION = "${getVersion()}"
}
stages {
stage('Init') {
steps {
container('platform11') {
sh """#!/bin/bash -e
jx step git credentials
git config credential.helper store
"""
}
}
}
stage('Build') {
environment {
MAVEN_OPTS = "-Xms512m -Xmx1g"
MAVEN_ARGS = getMavenArgs()
}
steps {
setGitHubBuildStatus('build')
container('platform11') {
sh "mvn ${MAVEN_ARGS}"
}
}
post {
always {
sh "find . -name '*-reports' -type d"
junit allowEmptyResults: true, testResults: '**/target/*-reports/*.xml'
archiveArtifacts artifacts: '**/target/*.log, **/log/*.log, **/nxserver/config/distribution.properties, ' +
'**/target/*-reports/*, **/target/results/*.html, **/target/*.png, **/target/*.html',
allowEmptyArchive: true
setGitHubBuildStatus('build')
}
}
}
stage('Upgrade version stream') {
when {
tag '*'
}
steps {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
container('platform11') {
sh """#!/bin/bash -xe
jx step create pr regex --regex 'version: (.*)' --version $VERSION --files packages/nuxeo-insight-client.yml -r https://github.com/nuxeo/jx-ai-versions
"""
}
}
}
}
}
post {
always {
script {
if (env.BRANCH_NAME ==~ 'master.*' || env.TAG_NAME || env.BRANCH_NAME ==~ 'sprint.*') {
step([$class: 'JiraIssueUpdater', issueSelector: [$class: 'DefaultIssueSelector'], scm: scm])
}
}
}
}
}