add jenkins release pipeline
[maven-build-process.git] / build / jenkins / Release
blob4361a4a661c541f82760111edfc16b5451158503
1 node {
2     stage('Checkout') {
3         checkout scm
4     }
6     stage('Versioning') {
7         def timestamp = new java.text.SimpleDateFormat('yyyy.MM.dd-HHmmss').format(new Date())
8         withMaven(
9             maven: 'maven-latest',
10             mavenSettingsConfig: 'repository.metio.wtf',
11             mavenLocalRepo: '.repository') {
12             try {
13                 sh "mvn versions:set -DgenerateBackupPoms=false -DnewVersion=${timestamp}"
14             } catch (exception) {
15                 currentBuild.result = 'FAILURE'
16                 throw exception
17             }
18         }
19     }
21     stage('Build & Deploy') {
22         withMaven(
23             maven: 'maven-latest',
24             mavenSettingsConfig: 'repository.metio.wtf',
25             mavenLocalRepo: '.repository') {
26             try {
27                 sh "mvn clean pgp:sign deploy scm:tag -Drelease=sonatype -DpushChanges=false"
28             } catch (exception) {
29                 currentBuild.result = 'FAILURE'
30             }
31         }
32     }
34     stage('Cleanup') {
35         dir('.repository') {
36             deleteDir()
37         }
38     }