provide config file during pipeline build
[maven-build-process.git] / build / jenkins / Preview
blob0a42831d8d7e23a11a169d9069670776e1b26a97
1 node {
2     stage('Checkout') {
3         checkout scm
4     }
6     stage('Versioning') {
7         withMaven(
8             maven: 'maven-latest',
9             mavenSettingsConfig: 'repository.metio.wtf',
10             mavenLocalRepo: '.repository') {
11             try {
12                 def timestamp = new java.text.SimpleDateFormat('yyyy.MM.dd-HHmmss').format(new Date())
13                 sh "mvn versions:set -DgenerateBackupPoms=false -DnewVersion=${timestamp}"
14             } catch (exception) {
15                 currentBuild.result = 'FAILURE'
16             }
17         }
18     }
20     stage('Build & Deploy') {
21         withCredentials([
22                 string(credentialsId: 'pgp.secretkey', variable: 'PGP_KEY'),
23                 string(credentialsId: 'pgp.passphrase', variable: 'PGP_PASSPHRASE')]) {
24             withMaven(
25                 maven: 'maven-latest',
26                 mavenLocalRepo: '.repository') {
27                 try {
28                     sh "git config user.name 'build.metio.wtf'"
29                     sh "git config user.email 'build@metio.wtf'"
30                     configFileProvider([configFile(fileId: 'repository.metio.wtf', variable: 'MAVEN_SETTINGS')]) {
31                         sh("mvn -s $MAVEN_SETTINGS clean pgp:sign deploy scm:tag -Drelease=metio -DpushChanges=false -DskipLocalStaging=true -Dpgp.secretKey=keyfile:${PGP_KEY} -Dpgp.passphrase=literal:'${PGP_PASSPHRASE}'")
32                     }
33                 } catch (exception) {
34                     currentBuild.result = 'FAILURE'
35                 }
36             }
37         }
38     }
40     stage('Cleanup') {
41         dir('.repository') {
42             deleteDir()
43         }
44     }