-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathJenkinsfile.library
50 lines (45 loc) · 1.64 KB
/
Jenkinsfile.library
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
#!groovy
doUpload = (env.BRANCH_NAME == 'master')
ansiColor('xterm') {
node('docker') {
stage('setup') {
if (env.BRANCH_NAME ==~ /.*\/.*/) {
error("Branch names must not contain slashes.")
}
checkout scm
}
def image = docker.build('primers-library:latest', "-f Dockerfile.build .")
stage('Build Library') {
image.inside() {
sh "rm -rf rlibrary"
sh "rm -rf renv-cache"
sh "mkdir -p rlibrary/"
sh "mkdir -p renv-cache/"
sh "RENV_PATHS_ROOT=renv-cache/ R -e 'renv::restore(library=\"rlibrary/\", repos=c(CRAN=\"https://packagemanager.rstudio.com/cran/__linux__/bionic/latest\"))'"
sh "tar -C rlibrary -zcvf bionic-r3-6-3.tar.gz ."
stash includes: 'bionic-r3-6-3.tar.gz', name: 'rlibrary'
}
print "Finished building"
}
stage('Upload') {
if (doUpload) {
image.inside() {
gitSHA = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
unstash 'rlibrary'
withCredentials([string(credentialsId: 'primers-role-name', variable: 'PRIMERS_ROLE_NAME')]) {
withCredentials([string(credentialsId: 'primers-role-account', variable: 'PRIMERS_ROLE_ACCOUNT')]) {
withAWS(role: PRIMERS_ROLE_NAME, roleAccount: PRIMERS_ROLE_ACCOUNT) {
sh "aws s3 cp bionic-r3-6-3.tar.gz s3://primers-library/r3.6.3/bionic/${gitSHA}.tar.gz"
}
}
}
}
} else {
print "Skipping"
}
}
stage('Finish') {
print "Finished pipeline"
}
}
}