-
Notifications
You must be signed in to change notification settings - Fork 16
/
Jenkinsfile
executable file
·74 lines (74 loc) · 1.88 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
pipeline {
agent any
tools {
maven 'Maven 3.8.5'
jdk 'OpenJDK11'
}
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
skipStagesAfterUnstable()
timestamps()
disableConcurrentBuilds()
}
parameters {
booleanParam(name: 'RELEASE', defaultValue: false, description: 'Make a Maven release')
}
stages {
stage('Validate') {
when {
allOf {
expression { params.RELEASE }
not {
branch 'master'
}
}
}
steps {
script {
error('Releases are only allowed from the master branch.')
}
}
}
stage('Set project version') {
steps {
script {
env.VERSION = """${sh(returnStdout: true, script: './build/get-version.sh ${RELEASE}')}"""
}
}
}
stage('Maven build') {
steps {
configFileProvider([configFile(fileId: 'org.jenkinsci.plugins.configfiles.maven.GlobalMavenSettingsConfig1387378707709', variable: 'MAVEN_SETTINGS')]) {
sh 'mvn -s $MAVEN_SETTINGS clean verify deploy -B -U'
}
}
}
stage('Release version to nexus') {
when {
allOf {
expression { params.RELEASE }
branch 'master'
}
}
steps {
configFileProvider([configFile(fileId: 'org.jenkinsci.plugins.configfiles.maven.GlobalMavenSettingsConfig1387378707709', variable: 'MAVEN_SETTINGS')]) {
git 'https://github.com/gbif/clustering.git'
sh 'mvn -s $MAVEN_SETTINGS release:prepare release:perform -Denforcer.skip=true -DskipTests'
}
}
}
stage('Build and publish Docker image') {
steps {
sh 'build/spark-generate-maps-docker-build.sh ${RELEASE} ${VERSION}'
}
}
}
post {
success {
echo 'Pipeline executed successfully!'
}
failure {
echo 'Pipeline execution failed!'
}
}
}