add prefix for secret key location
[maven-build-process.git] / build / jenkins / Release
blobf8ca61f7980ee28f5a4fad88f3ab5a43656413b9
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                 mavenSettingsConfig: 'repository.metio.wtf',
27                 mavenLocalRepo: '.repository') {
28                 try {
29                     sh("mvn clean pgp:sign deploy scm:tag -Drelease=sonatype -DpushChanges=false -Dpgp.secretKey=keyfile:${PGP_KEY} -Dpgp.passphrase=literal:'${PGP_PASSPHRASE}'")
30                 } catch (exception) {
31                     currentBuild.result = 'FAILURE'
32                 }
33             }
34         }
35     }
37     stage('Cleanup') {
38         dir('.repository') {
39             deleteDir()
40         }
41     }