update props to latest version
[maven-build-process.git] / build / jenkins / Preview
blob02ae1d145e60196e7ff22df8fd2272832e17e648
1 node {
3     def repositoryLocation = ".repository"
4     def timestamp = new java.text.SimpleDateFormat('yyyy.MM.dd-HHmmss').format(new Date())
5     def mavenVersion = "maven-latest"
6     def mavenSettings = "repository.metio.wtf"
7     def releaseTarget = "metio"
8     def skipLocalStaging = "true"
10     stage('Cleanup') {
11         deleteDir()
12     }
14     stage('Checkout') {
15         checkout scm
16     }
18     stage('Versioning') {
19         withMaven(
20                 maven: "${mavenVersion}",
21                 mavenSettingsConfig: "${mavenSettings}",
22                 mavenLocalRepo: "${repositoryLocation}") {
23             sh """
24                 mvn --batch-mode \
25                     --show-version \
26                     versions:set \
27                     -DgenerateBackupPoms=false \
28                     -DnewVersion=${timestamp}
29             """
30         }
31     }
33     stage('Analyze') {
34         withSonarQubeEnv('quality.metio.wtf') {
35             withMaven(
36                     maven: "${mavenVersion}",
37                     mavenSettingsConfig: "${mavenSettings}",
38                     mavenLocalRepo: "${repositoryLocation}") {
39                 sh """
40                     mvn --batch-mode \
41                         --show-version \
42                         sonar:sonar
43                 """
44             }
45         }
46     }
48     stage('Deploy') {
49         withCredentials([
50                 string(credentialsId: 'pgp.secretkey', variable: 'PGP_KEY'),
51                 string(credentialsId: 'pgp.passphrase', variable: 'PGP_PASSPHRASE')]) {
52             configFileProvider([configFile(fileId: "${mavenSettings}", variable: 'MAVEN_SETTINGS')]) {
53                 withMaven(
54                         maven: "${mavenVersion}",
55                         mavenLocalRepo: "${repositoryLocation}") {
56                     sh """
57                         mvn --batch-mode \
58                             --settings $MAVEN_SETTINGS \
59                             --show-version \
60                             pgp:sign deploy \
61                             -Drelease=${releaseTarget} \
62                             -DskipLocalStaging=${skipLocalStaging} \
63                             -Dpgp.secretKey=keyfile:${PGP_KEY} \
64                             -Dpgp.passphrase=literal:'${PGP_PASSPHRASE}'
65                     """
66                 }
67             }
68         }
69     }