forked from ProgrammeVitam/sedatools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
80 lines (72 loc) · 2.96 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
pipeline {
agent {
label 'slaves'
}
environment {
MVN_BASE = "/usr/local/maven/bin/mvn"
MVN_COMMAND = "${MVN_BASE} --settings ${pwd()}/.ci/settings.xml --show-version --batch-mode --errors --fail-at-end -DinstallAtEnd=true -DdeployAtEnd=true "
DEPLOY_GOAL = " " // Deploy goal used by maven ; typically "deploy" for master* branches & "" (nothing) for everything else (we don't deploy) ; keep a space so can work in other branches than develop
CI = credentials("app-jenkins")
SERVICE_SONAR_URL = credentials("service-sonar-url")
SERVICE_NEXUS_URL = credentials("service-nexus-url")
SERVICE_CHECKMARX_URL = credentials("service-checkmarx-url")
SERVICE_REPO_SSHURL = credentials("repository-connection-string")
SERVICE_GIT_URL = credentials("service-gitlab-url")
SERVICE_PROXY_HOST = credentials("http-proxy-host")
SERVICE_PROXY_PORT = credentials("http-proxy-port")
MAILEXTRACT_GIT_URL=credentials("mailextract-gitlab-url")
SERVICE_NOPROXY = credentials("http_nonProxyHosts")
}
triggers {
upstream(upstreamProjects: 'build-mailextractor', threshold: hudson.model.Result.SUCCESS)
}
stages {
stage("Tools configuration") {
steps {
echo "Workspace location : ${env.WORKSPACE}"
echo "Branch : ${env.GIT_BRANCH}"
// default behavior
writeFile file: 'deploy_goal.txt', text: "${env.DEPLOY_GOAL}"
}
}
// Override the default maven deploy target when on master (publish on nexus)
stage("Computing maven target") {
when {
anyOf {
branch "master"
tag pattern: "^[1-9]+\\.[0-9]+\\.[0-9]+-?[0-9]*\$", comparator: "REGEXP"
}
}
environment {
DEPLOY_GOAL = "deploy"
MASTER_BRANCH = "true"
}
steps {
script {
// overwrite file content with one more goal
writeFile file: 'deploy_goal.txt', text: "${env.DEPLOY_GOAL}"
writeFile file: 'master_branch.txt', text: "${env.MASTER_BRANCH}"
}
echo "We are on master branch (${env.GIT_BRANCH}) ; deploy goal is \"${env.DEPLOY_GOAL}\""
}
}
stage ("Execute unit tests") {
steps {
sh '$MVN_COMMAND -f pom.xml clean test '
}
post {
always {
junit '**/target/surefire-reports/*.xml'
}
}
}
stage("Build") {
environment {
DEPLOY_GOAL = readFile("deploy_goal.txt")
}
steps {
sh '$MVN_COMMAND -f pom.xml -Dmaven.test.skip=true -DskipTests=true clean package javadoc:aggregate-jar $DEPLOY_GOAL'
}
}
}
}