-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
65 lines (63 loc) · 2.15 KB
/
Jenkinsfile
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
59
60
61
62
63
64
65
#!/usr/bin/env groovy
pipeline {
agent any
tools {
maven 'maven-default'
jdk 'openjdk8-zulu'
}
stages {
stage ('Checking commit message') {
when {
allOf {
not {
buildingTag()
}
changelog '.*\\[maven-release-plugin\\].*'
}
}
steps {
script {
currentBuild.result = 'NOT_BUILT'
}
error('Skipping release build')
}
}
stage ('Build') {
steps {
sh 'mvn install -P docker,docker-it,build-extras,jenkins-ci'
}
}
stage ('Deploy') {
when {
not {
changeRequest()
}
}
steps {
withCredentials([
usernamePassword(credentialsId: 'dockerhub', usernameVariable: 'DOCKER_IO_USERNAME', passwordVariable: 'DOCKER_IO_TOKEN'),
usernamePassword(credentialsId: 'ossrh', usernameVariable: 'OSSRH_USERNAME', passwordVariable: 'OSSRH_TOKEN'),
usernamePassword(credentialsId: 'gpg', usernameVariable: 'GPG_KEY_NAME', passwordVariable: 'GPG_PASSPHRASE'),
file(credentialsId: 'mavensigningkey', variable: 'MAVEN_SIGNING_KEY')
]) {
sh "gpg --batch --fast-import ${env.MAVEN_SIGNING_KEY}"
sh 'mvn -DskipTests deploy -s cd/settings.xml -P sign,docker,build-extras'
}
}
}
stage ('Qualitiy - Sonar') {
steps {
withCredentials([
string(credentialsId: 'pro-crafting-sonarcloud', variable: 'SONARCLOUD_TOKEN')
]) {
sh "mvn org.jacoco:jacoco-maven-plugin:prepare-agent org.apache.maven.plugins:maven-surefire-plugin:test org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.login=${env.SONARCLOUD_TOKEN}"
}
}
}
}
post {
always {
cleanWs()
}
}
}