-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
48 lines (47 loc) · 2.21 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
#!groovy
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 (packages published on rc, master branches)')
string(name: 'ALT_DEPLOYMENT_REPOSITORY', defaultValue: '', description: 'Alternative deployment repo')
string(name: 'GPG_KEY_CREDENTIAL_ID', defaultValue: 'jenkins-jenkins-valuya-maven-deploy-gpg-key',
description: 'Credential containing the private gpg key (pem)')
string(name: 'GPG_KEY_FINGERPRINT', defaultValue: '98547E57F1690E2901E74CAB04EBAAA5BAB4A4DF',
description: 'The fingerprint of this key to add to trust root')
}
options {
disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr: '10'))
}
stages {
stage ('Build & deploy') {
steps {
script {
env.MVN_ARGS = ""
env.MVN_GOALS = "clean package"
env.DO_DEPLOY = false
if (params.ALT_DEPLOYMENT_REPOSITORY != '') {
env.MVN_ARGS = "${env.MVN_ARGS} -DaltDeploymentRepository=${params.ALT_DEPLOYMENT_REPOSITORY}"
}
if (params.SKIP_TESTS) {
env.MVN_ARGS = "${env.MVN_ARGS} -DskipTests=true"
}
if (env.BRANCH_NAME == "master" || env.BRANCH_NAME == "dev" || params.FORCE_DEPLOY == true) {
env.MVN_GOALS = "clean deploy"
env.MVN_ARGS = "${env.MVN_ARGS} -Possrh-deploy"
env.DO_DEPLOY = true
}
}
withCredentials([file(credentialsId: "${params.GPG_KEY_CREDENTIAL_ID}", variable: 'GPGKEY')]) {
sh 'gpg --allow-secret-key-import --import $GPGKEY'
sh "echo \"${params.GPG_KEY_FINGERPRINT}:6:\" | gpg --import-ownertrust"
}
withMaven(maven: 'maven', mavenSettingsConfig: 'ossrh-settings-xml', jdk: 'jdk17') {
sh "mvn $MVN_ARGS $MVN_GOALS"
}
}
}
}
}