This repository has been archived by the owner on Apr 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
/
Jenkinsfile
66 lines (59 loc) · 2.12 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
pipeline {
agent {
label 'linux'
}
parameters {
string(name: 'buildVersion', description: 'Build version', defaultValue: '1.0-SNAPSHOT-${BUILD_NUMBER}')
booleanParam(name: 'publish', description: 'Should the build be published to the Plugin Portal', defaultValue: false)
booleanParam(name: 'documentation', description: 'Should the documentation be published', defaultValue: false)
}
environment {
GRADLE_PUBLISH_KEY = credentials('GRADLE_PUBLISH_KEY')
GRADLE_PUBLISH_SECRET = credentials('GRADLE_PUBLISH_SECRET')
}
stages {
stage('Build') {
steps {
sh "./gradlew assemble -PBUILD_VERSION=${params.buildVersion}"
}
}
stage('Publish') {
when {
expression { params.publish }
}
steps {
sh "./gradlew publishPlugins -PBUILD_VERSION=${params.buildVersion} -Pgradle.publish.key=${env.GRADLE_PUBLISH_KEY} -Pgradle.publish.secret=${env.GRADLE_PUBLISH_SECRET}"
archiveArtifacts artifacts: '**/build/libs/*.jar', fingerprint: true
}
}
stage('Build Documentation') {
when {
expression { params.documentation }
}
steps {
sh "./gradlew groovydoc -PBUILD_VERSION=${params.buildVersion}"
}
}
stage('Publish Documentation') {
when {
expression { params.documentation }
}
steps {
sh "git checkout gh-pages"
sh "cp -r build/docs/groovydoc/* api"
sh "git add api"
sh "git -c user.name='Jenkins' -c user.email='[email protected]' commit -m \"Update Groovydoc for ${params.buildVersion}\""
sh "git tag -a ${params.buildVersion}-documentation"
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'GithubID', usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD']]) {
sh "git push https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/johndevs/gradle-vaadin-plugin.git"
}
sh "git checkout master"
}
}
stage('Cleanup') {
steps {
sh "./gradlew clean"
}
}
}
}