-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
50 lines (50 loc) · 2.06 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
pipeline {
agent any
parameters {
booleanParam(name: 'SKIP_TESTS', defaultValue: false, description: 'Skip tests')
booleanParam(name: 'FORCE_DEPLOY', defaultValue: false, description: 'Force deploy on feature branches')
string(name: 'ALT_DEPLOYMENT_REPOSITORY', defaultValue: '', description: 'Alternative deployment repo')
string(name: 'MVN_ARGS', defaultValue: '', description: 'Additional maven args')
}
options {
disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr: '10'))
}
stages {
stage ('Build') {
steps {
script {
env.MVN_ARGS=params.MVN_ARGS
if (params.ALT_DEPLOYMENT_REPOSITORY != '') {
env.MVN_ARGS="${env.MVN_ARGS} -DaltDeploymentRepository=${params.ALT_DEPLOYMENT_REPOSITORY}"
}
}
withMaven(maven: 'maven', mavenSettingsConfig: 'ossrh-settings-xml') {
sh "mvn -DskipTests=${params.SKIP_TESTS} clean compile install"
}
}
}
stage ('Publish') {
when { anyOf {
environment name: 'BRANCH_NAME', value: 'master'
environment name: 'BRANCH_NAME', value: 'rc'
expression { return params.FORCE_DEPLOY == true }
} }
steps {
script {
env.MVN_ARGS=params.MVN_ARGS
if (params.ALT_DEPLOYMENT_REPOSITORY != '') {
env.MVN_ARGS="${env.MVN_ARGS} -DaltDeploymentRepository=${params.ALT_DEPLOYMENT_REPOSITORY}"
}
if (env.BRANCH_NAME == 'master') {
env.MVN_ARGS="${env.MVN_ARGS} -Possrh-deploy"
}
}
withMaven(maven: 'maven', mavenSettingsConfig: 'ossrh-settings-xml',
mavenOpts: '-DskipTests=true') {
sh "mvn deploy $MVN_ARGS"
}
}
}
}
}