-
Notifications
You must be signed in to change notification settings - Fork 3
/
Jenkinsfile
119 lines (115 loc) · 3.71 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
podTemplate(
//idleMinutes : 30,
podRetention : onFailure(),
activeDeadlineSeconds : 3600,
containers: [
containerTemplate(
name: 'dtk-rpm-builder',
image: 'docker-production.packages.idmod.org/idm/dtk-rpm-builder:0.1',
command: 'sleep',
args: '30d'
)
]) {
node(POD_LABEL) {
container('dtk-rpm-builder'){
def build_ok = true
stage('Cleanup Workspace') {
cleanWs()
echo "Cleaned Up Workspace For Project"
echo "${params.BRANCH}"
}
stage('Prepare') {
sh 'python --version'
sh 'python3 --version'
sh 'pip3 --version'
sh 'python3 -m pip install --upgrade pip'
sh 'pip3 install wheel unittest-xml-reporting pytest'
sh 'python3 -m pip install --upgrade setuptools'
sh 'pip3 freeze'
}
stage('Code Checkout') {
if (env.CHANGE_ID) {
echo "I execute on the pull request ${env.CHANGE_ID}"
checkout([$class: 'GitSCM',
branches: [[name: "pr/${env.CHANGE_ID}/head"]],
doGenerateSubmoduleConfigurations: false,
extensions: [],
gitTool: 'Default',
submoduleCfg: [],
userRemoteConfigs: [[refspec: '+refs/pull/*:refs/remotes/origin/pr/*', credentialsId: '704061ca-54ca-4aec-b5ce-ddc7e9eab0f2', url: '[email protected]:InstituteforDiseaseModeling/emodpy-typhoid.git']]])
} else {
echo "I execute on the ${env.BRANCH_NAME} branch"
git branch: "${env.BRANCH_NAME}",
credentialsId: '704061ca-54ca-4aec-b5ce-ddc7e9eab0f2',
url: '[email protected]:InstituteforDiseaseModeling/emodpy-typhoid.git'
}
}
stage('Install') {
def curDate = sh(returnStdout: true, script: "date").trim()
echo "The current date is ${curDate}"
echo "I am installing emodpy-typhoid from github source code"
sh "pip3 install -r requirements.txt --index-url=https://packages.idmod.org/api/pypi/pypi-production/simple"
sh "pip3 list"
sh "pip3 install -e ."
sh "pip3 list"
}
stage('Login') {
withCredentials([usernamePassword(credentialsId: 'comps_jenkins_user', usernameVariable: 'COMPS_USERNAME', passwordVariable: 'COMPS_PASSWORD'),
usernamePassword(credentialsId: 'comps2_jenkins_user', usernameVariable: 'COMPS2_USERNAME', passwordVariable: 'COMPS2_PASSWORD')])
{
sh 'python3 .dev_scripts/create_auth_token_args.py --comps_url https://comps2.idmod.org --username $COMPS2_USERNAME --password $COMPS2_PASSWORD'
sh 'python3 .dev_scripts/create_auth_token_args.py --comps_url https://comps.idmod.org --username $COMPS_USERNAME --password $COMPS_PASSWORD'
}
}
try{
stage('Unit Test') {
echo "Running Unit test Tests"
dir('tests/unittests') {
sh 'py.test -sv --junitxml=reports/test_results.xml'
junit 'reports/*.xml'
}
}
} catch(e) {
build_ok = false
echo e.toString()
}
try{
stage('Workflow Test') {
echo "Running Workflow Tests"
dir('tests/workflow_tests') {
sh 'py.test -sv --junitxml=reports/test_results.xml'
junit 'reports/*.xml'
}
}
} catch(e) {
build_ok = false
echo e.toString()
}
try{
stage('SFT Test') {
echo "Running SFT Tests"
dir('tests/sft_tests') {
sh 'pip3 install idm-test>=0.1.2 --index-url=https://packages.idmod.org/api/pypi/pypi-production/simple'
sh 'python3 run_all_sft_tests.py'
junit '**/test_results.xml'
}
}
} catch(e) {
build_ok = false
echo e.toString()
}
// stage('Run Examples') {
// echo "Running examples"
// dir('examples') {
// sh 'pip3 install snakemake'
// sh 'snakemake --cores=4 --config python_version=python3'
// }
// }
if(build_ok) {
currentBuild.result = "SUCCESS"
} else {
currentBuild.result = "FAILURE"
}
}
}
}