Skip to content

Commit 411074f

Browse files
author
Nicusor Serban
committed
Refactor Jenkinsfile to use linux executors with a docker image
1 parent 667fb14 commit 411074f

1 file changed

Lines changed: 35 additions & 43 deletions

File tree

Jenkinsfile

Lines changed: 35 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env groovy
22

33
pipeline {
4-
agent { label 'gg-osx' }
4+
agent none
55
options {
66
skipDefaultCheckout()
77
preserveStashes(buildCount: 5)
@@ -19,14 +19,18 @@ pipeline {
1919
}
2020
stages {
2121
stage("Checkout docs, build and create PR") {
22+
agent {
23+
docker {
24+
image 'stanorg/ci:docs'
25+
label 'linux'
26+
}
27+
}
2228
when {
2329
expression {
2430
params.buildDocs
2531
}
2632
}
2733
steps{
28-
/* Checkout source code */
29-
deleteDir()
3034
checkout([$class: 'GitSCM',
3135
branches: [[name: '*/master']],
3236
doGenerateSubmoduleConfigurations: false,
@@ -35,13 +39,7 @@ pipeline {
3539
userRemoteConfigs: [[url: "https://github.com/stan-dev/docs.git", credentialsId: 'a630aebc-6861-4e69-b497-fd7f496ec46b']]]
3640
)
3741

38-
/* Create a new branch */
39-
withCredentials([usernamePassword(credentialsId: 'a630aebc-6861-4e69-b497-fd7f496ec46b',
40-
usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD')]) {
41-
sh """#!/bin/bash
42-
git checkout -b docs-$major_version-$minor_version
43-
"""
44-
}
42+
sh "ls -lhart"
4543

4644
/* Build docs */
4745
sh "python3 build.py $major_version $minor_version"
@@ -65,10 +63,12 @@ pipeline {
6563
/* Create Pull Request */
6664
withCredentials([usernamePassword(credentialsId: 'a630aebc-6861-4e69-b497-fd7f496ec46b',
6765
usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD')]) {
68-
sh """#!/bin/bash
69-
git config --global user.email "mc.stanislaw@gmail.com"
70-
git config --global user.name "Stan Jenkins"
71-
git config --global auth.token ${GITHUB_TOKEN}
66+
sh """
67+
git config user.email "mc.stanislaw@gmail.com"
68+
git config user.name "Stan Jenkins"
69+
git config auth.token ${GITHUB_TOKEN}
70+
71+
git checkout -b docs-$major_version-$minor_version
7272
7373
git add .
7474
git commit -m "Documentation generated from Jenkins for docs-$major_version-$minor_version"
@@ -77,17 +77,23 @@ pipeline {
7777
curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X POST -d '{"title": "Docs generated by Jenkins for v$major_version-$minor_version", "head":"docs-$major_version-$minor_version", "base":"master", "body":"Docs generated through the [Jenkins Job](https://jenkins.flatironinstitute.org/job/Stan/job/BuildDocs/)"}' "https://api.github.com/repos/stan-dev/docs/pulls"
7878
"""
7979
}
80+
81+
deleteDir()
8082
}
8183
}
8284
stage('Checkout stan-dev.github.io and update docs version') {
85+
agent {
86+
docker {
87+
image 'stanorg/ci:docs'
88+
label 'linux'
89+
}
90+
}
8391
when {
8492
expression {
8593
params.docsStanDev
8694
}
8795
}
8896
steps {
89-
/* Checkout source code */
90-
deleteDir()
9197
checkout([$class: 'GitSCM',
9298
branches: [[name: '*/master']],
9399
doGenerateSubmoduleConfigurations: false,
@@ -96,14 +102,6 @@ pipeline {
96102
userRemoteConfigs: [[url: "https://github.com/stan-dev/stan-dev.github.io.git", credentialsId: 'a630aebc-6861-4e69-b497-fd7f496ec46b']]]
97103
)
98104

99-
/* Switch to a new branch */
100-
withCredentials([usernamePassword(credentialsId: 'a630aebc-6861-4e69-b497-fd7f496ec46b', usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD')]) {
101-
sh """#!/bin/bash
102-
git checkout -b docs-$major_version-$minor_version
103-
104-
"""
105-
}
106-
107105
/* Format version numbers with dot and underscore then replace the old values */
108106
script {
109107
def last_version_parts = last_docs_version_dir.split("_")
@@ -112,30 +110,23 @@ pipeline {
112110
def new_version_dot = major_version + "." + minor_version
113111

114112
/* Linux Version */
115-
//sh """
116-
//sed -i 's/$last_docs_version_dir/$new_version_underscore/g' users/documentation/index.md
117-
//sed -i 's/$last_version_dot/$new_version_dot/g' users/documentation/index.md
118-
//sed -i 's/$last_docs_version_dir/$new_version_underscore/g' users/interfaces/cmdstan.md
119-
//sed -i 's/$last_version_dot/$new_version_dot/g' users/interfaces/cmdstan.md
120-
//"""
121-
122-
/* Mac Version */
123113
sh """
124-
sed -i.bak 's/$last_docs_version_dir/$new_version_underscore/g' users/documentation/index.md
125-
sed -i.bak 's/$last_version_dot/$new_version_dot/g' users/documentation/index.md
126-
sed -i.bak 's/$last_docs_version_dir/$new_version_underscore/g' users/interfaces/cmdstan.md
127-
sed -i.bak 's/$last_version_dot/$new_version_dot/g' users/interfaces/cmdstan.md
114+
sed -i 's/$last_docs_version_dir/$new_version_underscore/g' users/documentation/index.md
115+
sed -i 's/$last_version_dot/$new_version_dot/g' users/documentation/index.md
116+
sed -i 's/$last_docs_version_dir/$new_version_underscore/g' users/interfaces/cmdstan.md
117+
sed -i 's/$last_version_dot/$new_version_dot/g' users/interfaces/cmdstan.md
128118
"""
129-
130119
}
131120

132121
/* Create a merge request */
133122
withCredentials([usernamePassword(credentialsId: 'a630aebc-6861-4e69-b497-fd7f496ec46b',
134123
usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD')]) {
135-
sh """#!/bin/bash
136-
git config --global user.email "mc.stanislaw@gmail.com"
137-
git config --global user.name "Stan Jenkins"
138-
git config --global auth.token ${GITHUB_TOKEN}
124+
sh """
125+
git config user.email "mc.stanislaw@gmail.com"
126+
git config user.name "Stan Jenkins"
127+
git config auth.token ${GITHUB_TOKEN}
128+
129+
git checkout -b docs-$major_version-$minor_version
139130
140131
git add .
141132
git commit -m "Documentation generated from Jenkins for docs-$major_version-$minor_version"
@@ -144,8 +135,9 @@ pipeline {
144135
curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X POST -d '{"title": "Docs updated by Jenkins for v$major_version-$minor_version", "head":"docs-$major_version-$minor_version", "base":"master", "body":"Docs updated through the [Jenkins Job](https://jenkins.flatironinstitute.org/job/Stan/job/BuildDocs/)"}' "https://api.github.com/repos/stan-dev/stan-dev.github.io/pulls"
145136
"""
146137
}
147-
138+
deleteDir()
148139
}
140+
149141
}
150142
}
151-
}
143+
}

0 commit comments

Comments
 (0)