-
Notifications
You must be signed in to change notification settings - Fork 26
/
Jenkinsfile
122 lines (121 loc) · 5.19 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
pipeline {
environment {
BINTRAY_API_KEY = credentials("BINTRAY_API_KEY")
SONARQUBE_TOKEN = credentials("SONARQUBE_TOKEN")
GIT_ASKPASS = credentials("GIT_ASKPASS")
VER = "0.7.3"
}
agent any
parameters {
booleanParam(defaultValue: false, description: 'Build and deploy gitbook pages?', name: 'deployPages')
booleanParam(defaultValue: false, description: 'Publish new release from this build?', name: 'release')
string(defaultValue: "", description: 'New release version', name: 'releaseVersion')
string(defaultValue: "-SNAPSHOT", description: 'New release development', name: 'newVersion')
}
stages {
stage("Build") {
steps {
sh "git config --global credential.helper cache"
sh "./gradlew assemble testClasses integrationTestClasses"
}
}
stage("Unit Test") {
steps {
sh "./gradlew test"
}
}
stage("Integration Test") {
steps {
sh "./gradlew integrationTest"
}
}
stage("QA") {
when {
expression {
return env.RELEASE != "true"
}
}
steps {
sh "./gradlew junit5CodeCoverageReport"
sh "./gradlew sonarqube -Dsonar.host.url=https://sonarqube.com -Dsonar.login=${env.SONARQUBE_TOKEN} | grep -v 'Class not found:'"
publishHTML target: [
allowMissing : false,
alwaysLinkToLastBuild: false,
keepAll : true,
reportDir : 'build/reports/jacoco',
reportFiles : 'index.html',
reportName : 'Coverage report'
]
}
}
stage("Deploy pages") {
when {
expression {
boolean publish = false
if (env.DEPLOYPAGES == "true") {
return true
}
try {
timeout(time: 1, unit: 'MINUTES') {
input 'Deploy pages?'
publish = true
}
} catch (final ignore) {
publish = false
}
return publish
}
}
steps {
sh "./gradlew javadoc >/dev/null"
sh "rm -rf ./src/book/javadoc"
sh "mv ./build/docs/javadoc ./src/book/javadoc"
sh "gitbook install ./src/book/"
sh "gitbook build ./src/book/ ./repo"
sh "git --work-tree=repo/ --git-dir=repo/.git init"
sh "git --work-tree=repo/ --git-dir=repo/.git config user.name 'jenkins'"
sh "git --work-tree=repo/ --git-dir=repo/.git config user.email 'jenkins@ci.pojo.pl'"
sh "git --work-tree=repo/ --git-dir=repo/.git remote add origin git@github.com:sta-szek/pojo-tester.git"
sh "git --work-tree=repo/ --git-dir=repo/.git fetch -q -n origin"
sh "git --work-tree=repo/ --git-dir=repo/.git reset -q origin/gh-pages"
sh "git --work-tree=repo/ --git-dir=repo/.git add -A ."
sh "git --work-tree=repo/ --git-dir=repo/.git commit -m 'Rebuild pojo-tester pages by jenkins'"
sh "git --work-tree=repo/ --git-dir=repo/.git push origin HEAD:gh-pages"
}
}
stage("Publish release to bintray") {
when {
expression {
return env.BRANCH_NAME == "master" && env.RELEASE == "true" && env.RELEASEVERSION != "" && env.NEWVERSION != ""
}
}
steps {
sh "git checkout -f master"
sh "git config --global push.default simple"
sh "git remote remove origin"
sh "git remote add origin https://${env.GIT_ASKPASS}@github.com/sta-szek/pojo-tester.git"
sh "sed -i 's|version=.*|version=${env.RELEASEVERSION}|g' gradle.properties"
sh "git tag ${env.RELEASEVERSION}"
sh "./gradlew clean build bintrayUpload -x check"
sh "sed -i 's|version=.*|version=${env.NEWVERSION}|g' gradle.properties"
sh "git add gradle.properties"
sh "git commit -m 'Next development version ${env.NEWVERSION}'"
sh "git push --set-upstream origin ${env.RELEASEVERSION}"
sh "git push --set-upstream origin master"
}
post {
success {
rocketSend channel: 'pojo-tester',
rawMessage: true,
avatar: 'http://ci.pojo.pl/static/be09d97b/images/headshot.png',
message: "@all: *pojo-tester ${env.RELEASEVERSION} released!* \n https://bintray.com/sta-szek/maven/pojo-tester/_latestVersion \n"
}
}
}
}
post {
always {
deleteDir()
}
}
}