-
Notifications
You must be signed in to change notification settings - Fork 12
/
Jenkinsfile
81 lines (81 loc) · 2.49 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
pipeline {
agent {
kubernetes {
defaultContainer 'ubuntu'
activeDeadlineSeconds 3600
}
}
options {
ansiColor('xterm')
}
stages {
stage('Init') {
steps {
checkout scm
script {
def m = (env.GIT_URL =~ /(\/|:)(([^\/]+)\/)?(([^\/]+?)(\.git)?)$/)
if (m) {
org = m.group(3)
repo = m.group(5)
}
}
}
}
stage('Setup build') {
when { not { buildingTag() } }
steps {
script {
target = "verify"
}
}
}
stage('Setup release') {
when { buildingTag(); not { changeRequest() } }
steps {
script {
target = "deploy -P release -P rpm --settings settings.xml"
}
sh 'gpg --batch --import arpnetworking.key'
}
}
stage('Build') {
steps {
withCredentials([usernamePassword(credentialsId: 'jenkins-dockerhub', usernameVariable: 'DOCKER_USERNAME', passwordVariable: 'DOCKER_PASSWORD'),
usernamePassword(credentialsId: 'jenkins-ossrh', usernameVariable: 'OSSRH_USER', passwordVariable: 'OSSRH_PASS'),
string(credentialsId: 'jenkins-gpg', variable: 'GPG_PASS')]) {
withMaven {
sh "./jdk-wrapper.sh ./mvnw $target -P rpm -U -B -Dstyle.color=always -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -Ddocker.verbose=true"
}
}
}
}
stage('GitHub release') {
when { buildingTag(); not { changeRequest() } }
steps {
withCredentials([usernamePassword(credentialsId: 'brandonarp-github-token', usernameVariable: 'GITHUB_USERNAME', passwordVariable: 'GITHUB_TOKEN')]) {
sh "github-release release --user ${org} --repo ${repo} --tag ${TAG_NAME}"
sh "sleep 5"
sh "github-release upload --user ${org} --repo ${repo} --tag ${TAG_NAME} --name ${TAG_NAME}.tgz --file target/*.tgz"
sh "github-release upload --user ${org} --repo ${repo} --tag ${TAG_NAME} --name ${TAG_NAME}.rpm --file target/rpm/*/RPMS/*/*.rpm"
}
}
}
stage('Save cache') {
when {
branch 'master'
}
steps {
withMaven {
sh "./jdk-wrapper.sh ./mvnw -Ddocker.image.tag=cache-base -Ddocker.push.registry=docker.arpnetworking.com docker:push"
}
}
}
}
post('Analysis') {
always {
recordIssues(
enabledForFailure: true, aggregatingResults: true,
tools: [java(), checkStyle(reportEncoding: 'UTF-8'), spotBugs()])
}
}
}