forked from aramis-lab/clinica
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
162 lines (160 loc) · 5.44 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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/usr/bin/env groovy
// Continuous Integration script for Clinica
// www.clinica.run
// Author: [email protected]
pipeline {
agent none
stages {
stage('Build Env') {
parallel {
stage('Build in Linux') {
agent { label 'ubuntu' }
environment {
PATH = "$HOME/miniconda/bin:$PATH"
}
when { changeset "environment.yml" }
steps {
echo 'Building Conda environment... ${BRANCH_NAME}'
sh 'ls'
sh 'conda env create --force --file environment.yml -n clinica_env_${BRANCH_NAME}'
}
}
stage('Build in Mac') {
agent { label 'macos' }
environment {
PATH = "$HOME/miniconda3/bin:$PATH"
}
when { changeset "environment.yml" }
steps {
echo 'Building Conda environment...' + 'env.BRANCH_NAME'
sh 'ls'
sh 'conda env create --force --file environment.yml -n clinica_env_${BRANCH_NAME}'
}
}
}
}
stage('Install') {
parallel {
stage('Launch in Linux') {
agent { label 'ubuntu' }
environment {
PATH = "$HOME/miniconda/bin:$PATH"
}
steps {
echo 'Installing Clinica sources in Linux...'
echo 'My branch name is ${BRANCH_NAME}'
sh 'echo "My branch name is ${BRANCH_NAME}"'
sh 'printenv'
sh 'echo "Agent name: ${NODE_NAME}"'
script {
echo "My conda env name is clinica_env_${BRANCH_NAME}"
}
sh '''
set +x
./.jenkins/scripts/find_env.sh
conda info --envs
eval "$(conda shell.bash hook)"
conda activate clinica_env_$BRANCH_NAME
echo "Install clinica using pip..."
pip install --ignore-installed .
eval "$(register-python-argcomplete clinica)"
# Show clinica help message
echo "Display clinica help message"
clinica --help
conda deactivate
'''
}
}
stage('Launch in MacOS') {
agent { label 'macos' }
environment {
PATH = "$HOME/miniconda3/bin:$PATH"
}
steps {
echo 'Installing Clinica sources in MacOS...'
sh 'echo "Agent name: ${NODE_NAME}"'
sh '''
set +x
./.jenkins/scripts/find_env.sh
eval "$(conda shell.bash hook)"
conda activate clinica_env_$BRANCH_NAME
echo "Install clinica using pip..."
pip install --ignore-installed .
eval "$(register-python-argcomplete clinica)"
# Show clinica help message
echo "Display clinica help message"
clinica --help
conda deactivate
'''
}
}
}
}
stage('Short Tests') {
parallel {
stage('Instantiate Linux') {
agent { label 'ubuntu' }
environment {
PATH = "$HOME/miniconda/bin:/usr/local/Modules/bin:$PATH"
CLINICA_ENV_BRANCH = "clinica_env_$BRANCH_NAME"
WORK_DIR_LINUX = "/mnt/data/ci/working_dir_linux"
}
steps {
echo 'Testing pipeline instantation...'
sh 'echo "Agent name: ${NODE_NAME}"'
sh '''
set +x
./.jenkins/scripts/find_env.sh
eval "$(conda shell.bash hook)"
conda activate clinica_env_$BRANCH_NAME
source /usr/local/Modules/init/profile.sh
module load clinica.all
cd test
ln -s /mnt/data/ci/data_ci_linux ./data
taskset -c 0-21 pytest \
--verbose \
--working_directory=$WORK_DIR_LINUX \
--disable-warnings \
--timeout=0 \
-n 6 \
-k 'test_instantiate'
module purge
conda deactivate
'''
}
}
stage('Instantiate Mac') {
agent { label 'macos' }
environment {
PATH = "$HOME/miniconda3/bin:/usr/local/Cellar/modules/4.1.2/bin:$PATH"
CLINICA_ENV_BRANCH = "clinica_env_$BRANCH_NAME"
}
steps {
echo 'Testing pipeline instantation...'
sh 'echo "Agent name: ${NODE_NAME}"'
sh '''
set +x
./.jenkins/scripts/find_env.sh
eval "$(conda shell.bash hook)"
conda activate clinica_env_$BRANCH_NAME
source /usr/local/opt/modules/init/bash
module load clinica.all
cd test
ln -s /Volumes/data/data_ci ./data
pytest --verbose --disable-warnings -k 'test_instantiate'
module purge
conda deactivate
'''
}
}
}
}
}
post {
failure {
mail to: '[email protected]',
subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
body: "Something is wrong with ${env.BUILD_URL}"
}
}
}