File: JenkinsfileRelease

package info (click to toggle)
libsemantic-version-java 2.1.1%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 308 kB
  • sloc: java: 2,843; xml: 173; makefile: 2
file content (58 lines) | stat: -rw-r--r-- 1,798 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
pipeline {
  agent {
    docker {
      image 'maven:3.6-jdk-11'
      args '-v /home/jenkins/.m2:/var/maven/.m2 -v /home/jenkins/.gnupg:/.gnupg -e MAVEN_CONFIG=/var/maven/.m2 -e MAVEN_OPTS=-Duser.home=/var/maven'
    }
  }
  environment {
    GPG_SECRET = credentials('gpg_password')
    GITHUB = credentials('Github-Username-Pw')
    GITHUB_RELEASE_TOKEN = credentials('github_registry_release')
    GIT_ASKPASS='./.git-askpass'
  }
  stages {
    stage ('Ensure dev branch') {
      when {
        expression {
            return env.BRANCH_NAME != 'dev';
        }
      }
      steps {
        error("Releasing is only possible from dev branch")
      }
    }
    stage ('Set Git Information') {
      steps {
        sh 'echo \'echo \$GITHUB_PSW\' > ./.git-askpass'
        sh 'chmod +x ./.git-askpass'
        sh 'git config url."https://api@github.com/".insteadOf "https://github.com/"'
        sh 'git config url."https://ssh@github.com/".insteadOf "ssh://git@github.com/"'
        sh 'git config url."https://git@github.com/".insteadOf "git@github.com:"'
        sh 'git config user.email "build@taddiken.online"'
        sh 'git config user.name "Jenkins"'
      }
    }
    stage('Create release branch') {
      steps {
        sh 'mvn -B -Prelease gitflow:release-start'
      }
    }
    stage('Verify release') {
      steps {
        sh 'mvn -B -Prelease -Dgpg.passphrase=${GPG_SECRET} verify'
      }
    }
    stage('Perform release') {
      steps {
        sh "mvn -B gitflow:release-finish -DargLine=\"-Prelease -B -Dgpg.passphrase=${GPG_SECRET} -DskipTests\""
      }
    }
    stage('Create GitHub release') {
      steps {
        sh 'git checkout master'
        sh "mvn -B github-release:github-release -Dgithub.release-token=${GITHUB_RELEASE_TOKEN}"
      }
    }
  }
}