-
Notifications
You must be signed in to change notification settings - Fork 31
/
Jenkinsfile
executable file
·75 lines (65 loc) · 2.67 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
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 'scriptsCI/ciBuildVersion.sh ${BRANCH_NAME}'
stage 'Download and cache dependencies'
sh 'scriptsCI/ciDownloadDependencies.sh'
lock('cytomine-instance-test') {
stage 'Run external tools (db, amqp,...)'
catchError {
sh 'docker-compose -f scriptsCI/docker-compose.yml down -v'
}
sh 'docker-compose -f scriptsCI/docker-compose.yml up -d'
stage 'Build and test'
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh 'scriptsCI/ciTest.sh'
}
stage 'Publish test'
step([$class: 'JUnitResultArchiver', testResults: '**/ci/test-reports/TESTS-TestSuites.xml'])
catchError {
sh 'docker-compose -f scriptsCI/docker-compose.yml down -v'
}
}
stage 'Build war'
sh 'scriptsCI/ciBuildWar.sh'
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 war (private)'
sh 'scriptsCI/ciPublishWarPrivate.sh'
stage 'Build docker image (private)'
withCredentials(
[
usernamePassword(credentialsId: 'CYTOMINE_DOCKER_REGISTRY', usernameVariable: 'DOCKERHUB_USER', passwordVariable: 'DOCKERHUB_TOKEN')
]
) {
docker.withRegistry('http://repository.cytom.in:5004/v2/', 'CYTOMINE_DOCKER_REGISTRY') {
sh 'scriptsCI/ciBuildDockerImagePrivate.sh'
}
}
} else {
stage 'Publish war'
sh 'scriptsCI/ciPublishWar.sh'
stage 'Build docker image'
withCredentials(
[
usernamePassword(credentialsId: 'DOCKERHUB_CREDENTIAL', usernameVariable: 'DOCKERHUB_USER', passwordVariable: 'DOCKERHUB_TOKEN')
]
) {
docker.withRegistry('https://index.docker.io/v1/', 'DOCKERHUB_CREDENTIAL') {
sh 'scriptsCI/ciBuildDockerImage.sh'
}
}
}
}
}