-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
72 lines (64 loc) · 1.92 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
// Mirror repository on DMSC GitLab and publish documentation to GitHub.
properties([disableConcurrentBuilds()])
node('docker') {
// Delete workspace when build is done.
cleanWs()
dir('code') {
stage('Checkout') {
scmVars = checkout scm
}
stage('Create documentation') {
sh """
/ess/ecdc/groovy/current/bin/groovydoc -sourcepath src -d ../docs 'ecdcpipeline' '*.groovy'
"""
} // stage
if (env.BRANCH_NAME == "master" || env.BRANCH_NAME == "test-library") {
stage('Push to GitLab') {
withCredentials([
gitUsernamePassword(
credentialsId: 'dmsc-gitlab-username-with-token',
gitToolName: 'Default'
)
]) {
sh '''
git checkout $BRANCH_NAME
git push --force http://git.esss.dk/dm_group/jenkins-shared-library.git $BRANCH_NAME
'''
} // withCredentials
} // stage
} // if
} // dir
if (env.BRANCH_NAME == 'master') {
dir('code') {
stage('Publish documentation') {
withCredentials([string(
credentialsId: 'jenkins-notification-email',
variable: 'NOTIFICATION_EMAIL'
)]) {
sh '''
git config user.email $NOTIFICATION_EMAIL
git config user.name cow-bot
git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'
'''
} // withCredentials
sh """
git fetch
git checkout gh-pages
rm -rf *
mv ../docs/* .
git status
git add .
git commit -m 'Jenkins build ${env.BUILD_NUMBER} for ${scmVars.GIT_COMMIT}'
"""
withCredentials([
gitUsernamePassword(
credentialsId: 'cow-bot-username-with-token',
gitToolName: 'Default'
)
]) {
sh 'git push'
} // withCredentials
} // stage
} // dir
} // if
}