-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathJenkinsfileSCM
More file actions
121 lines (120 loc) · 4.38 KB
/
JenkinsfileSCM
File metadata and controls
121 lines (120 loc) · 4.38 KB
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
pipeline {
agent none
options {
buildDiscarder(logRotator(numToKeepStr: '3'))
}
environment {
IMAGE = 'patientprofilesvis'
NS = 'shared'
REGISTRY = 'registry.openanalytics.eu'
TAG = env.BRANCH_NAME.toLowerCase().replaceAll(/[^a-z0-9._-]/, '.').trim()
REGION = 'eu-west-1'
NOT_CRAN = 'true'
_R_CHECK_TESTS_NLINES_ = 0
}
stages {
stage('Build Image') {
agent {
kubernetes {
yaml '''
spec:
containers:
- name: kaniko
resources:
requests:
memory: 5Gi
limits:
memory: 10Gi
'''
inheritFrom 'kaniko'
yamlMergeStrategy merge()
}
}
steps {
container('kaniko') {
sh """/kaniko/executor \
-v info \
--log-timestamp=true \
--context ${env.WORKSPACE} \
--cache=true \
--cache-ttl=8760h0m0s \
--cache-repo ${env.REGISTRY}/${env.NS}/${env.IMAGE} \
--cleanup \
--destination ${env.REGISTRY}/${env.NS}/${env.IMAGE}:${env.TAG} \
--registry-mirror ${env.REGISTRY}"""
}
}
post {
always {
sh "cp /kaniko/jenkins/mem*.log ${env.WORKSPACE}"
archiveArtifacts artifacts: 'mem*.log', fingerprint: true
}
}
}
stage('Packages') {
agent {
kubernetes {
yaml """
apiVersion: v1
kind: Pod
spec:
containers:
- name: r
image: ${env.REGISTRY}/${env.NS}/${env.IMAGE}:${env.TAG}
resources:
limits:
cpu: 250m
memory: 1Gi
requests:
cpu: 250m
memory: 250Mi"""
inheritFrom 'r'
yamlMergeStrategy merge()
defaultContainer 'r'
}
}
stages {
stage('patientProfilesVis') {
stages {
stage('Roxygen') {
steps {
sh 'R -q -e \'roxygen2::roxygenize("patientProfilesVis")\''
}
}
stage('Build') {
steps {
sh 'R CMD build patientProfilesVis'
}
}
stage('Check') {
steps {
script() {
switch(sh(script: 'ls patientProfilesVis_*.tar.gz && R CMD check patientProfilesVis_*.tar.gz', returnStatus: true)) {
case 0: currentBuild.result = 'SUCCESS'
default: currentBuild.result = 'FAILURE'; error('script exited with failure status')
}
}
}
}
stage('Install') {
steps {
sh 'R -q -e \'install.packages(list.files(".", "patientProfilesVis_.*.tar.gz"), repos = NULL)\''
}
}
}
}
stage('Archive artifacts') {
steps {
archiveArtifacts artifacts: '*.tar.gz, *.pdf', fingerprint: true
}
}
}
post {
always {
sh "cp /mem_r.log ${env.WORKSPACE}"
archiveArtifacts artifacts: '**/00check.log, mem*.log', fingerprint: true, allowEmptyArchive: true
}
}
}
}
}