-
Notifications
You must be signed in to change notification settings - Fork 9
/
Jenkinsfile
executable file
·78 lines (59 loc) · 2.23 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
node {
stage 'Retrieve sources'
checkout([
$class: 'GitSCM',
branches: [[name: 'refs/heads/'+env.BRANCH_NAME]],
extensions: [[$class: 'CloneOption', noTags: false, shallow: false, depth: 0, reference: '']],
userRemoteConfigs: scm.userRemoteConfigs,
])
stage 'Clean'
sh 'rm -rf ./ci'
sh 'mkdir -p ./ci'
stage 'Compute version name'
sh 'scripts/ciBuildVersion.sh ${BRANCH_NAME}'
stage 'Download and cache dependencies'
sh 'scripts/ciDownloadDependencies.sh'
lock('cytomine-instance-test') {
stage 'Run cytomine instance'
catchError {
sh 'docker-compose -f scripts/docker-compose.yml down -v'
}
sh 'docker-compose -f scripts/docker-compose.yml up -d'
sleep(time:30,unit:"SECONDS") // wait for cytomine, TODO: we should wait in the js code (retry connection).
stage 'Build and test'
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh 'scripts/ciTest.sh'
}
stage 'Publish test'
step([$class: 'JUnitResultArchiver', testResults: 'ci/test-reports/*.xml'])
stage 'Clear cytomine instance'
catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
sh 'docker-compose -f scripts/docker-compose.yml down -v'
}
}
stage 'Publish if official release'
withFolderProperties{
// if PRIVATE is define in jenkins, the war and the docker image are send to the private cytomine repository.
// otherwise, public repo for war and public dockerhub repo for docker image
echo("Private: ${env.PRIVATE}")
if (env.PRIVATE && env.PRIVATE.equals("true")) {
stage 'Publish package (private)'
withCredentials(
[
string(credentialsId: 'NPM_TOKEN', variable: 'NPM_TOKEN')
]
) {
sh 'scripts/ciPublishPrivate.sh'
}
} else {
stage 'Publish package (public)'
withCredentials(
[
string(credentialsId: 'NPM_TOKEN', variable: 'NPM_TOKEN')
]
) {
sh 'scripts/ciPublishPublic.sh'
}
}
}
}