update props to latest version
[maven-build-process.git] / build / jenkins / Release
blob8d1122170d97418c525d8c8f55a1a9eba20e20fe
1 node {
3     def projectName = "sebhoss/maven-build-process"
4     def repositoryLocation = ".repository"
5     def timestamp = new java.text.SimpleDateFormat('yyyy.MM.dd-HHmmss').format(new Date())
6     def mavenVersion = "maven-latest"
7     def mavenSettings = "repository.metio.wtf"
8     def releaseTarget = "sonatype"
9     def skipLocalStaging = "false"
10     def githubCredentials = "build-metio-wtf-github"
12     stage('Cleanup') {
13         deleteDir()
14     }
16     stage('Checkout') {
17         checkout scm
18     }
20     stage('Versioning') {
21         withMaven(
22                 maven: "${mavenVersion}",
23                 globalMavenSettingsConfig: "${mavenSettings}",
24                 mavenLocalRepo: "${repositoryLocation}") {
25             sh """
26                 mvn --batch-mode \
27                     --show-version \
28                     versions:set \
29                     -DgenerateBackupPoms=false \
30                     -DnewVersion=${timestamp}
31             """
32         }
33     }
35     stage('Analyze') {
36         withSonarQubeEnv('quality.metio.wtf') {
37             withMaven(
38                     maven: "${mavenVersion}",
39                     globalMavenSettingsConfig: "${mavenSettings}",
40                     mavenLocalRepo: "${repositoryLocation}") {
41                 sh """
42                     mvn --batch-mode \
43                         --show-version \
44                         sonar:sonar
45                 """
46             }
47         }
48     }
50     stage('Deploy') {
51         withCredentials([
52                 string(credentialsId: 'pgp.secretkey', variable: 'PGP_KEY'),
53                 string(credentialsId: 'pgp.passphrase', variable: 'PGP_PASSPHRASE')]) {
54             configFileProvider([configFile(fileId: "${mavenSettings}", variable: 'MAVEN_SETTINGS')]) {
55                 withMaven(
56                         maven: "${mavenVersion}",
57                         mavenLocalRepo: "${repositoryLocation}") {
58                     sh """
59                         mvn --batch-mode \
60                             --settings $MAVEN_SETTINGS \
61                             --show-version \
62                             org.kohsuke:pgp-maven-plugin:sign deploy \
63                             -Drelease=${releaseTarget} \
64                             -DskipLocalStaging=${skipLocalStaging} \
65                             -Dpgp.secretKey=keyfile:${PGP_KEY} \
66                             -Dpgp.passphrase=literal:'${PGP_PASSPHRASE}'
67                     """
68                 }
69             }
70         }
71     }
73     stage('Git config') {
74         withCredentials([
75                 string(credentialsId: 'git.user.name', variable: 'GIT_USER'),
76                 string(credentialsId: 'git.user.email', variable: 'GIT_EMAIL')]) {
77             sh "git config user.name '${GIT_USER}'"
78             sh "git config user.email '${GIT_EMAIL}'"
79         }
80     }
82     stage('Tag') {
83         withMaven(
84                 maven: "${mavenVersion}",
85                 mavenSettingsConfig: "${mavenSettings}",
86                 mavenLocalRepo: "${repositoryLocation}") {
87             sh """
88                 mvn --batch-mode \
89                     --show-version \
90                     scm:tag \
91                     -DpushChanges=false
92             """
93         }
94     }
96     stage('Git Push') {
97         withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: "${githubCredentials}",
98                             usernameVariable: 'USERNAME', passwordVariable: 'TOKEN']]) {
99             sh "git push https://${TOKEN}:x-oauth-basic@github.com/${projectName}.git --tags"
100         }
101     }