Newer
Older
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
pipeline {
agent {
label 'contrib'
}
environment {
SLACK_MESSAGE = "${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.RUN_DISPLAY_URL}|Open>)"
MVN_BASE = "/usr/local/maven/bin/mvn --settings ${pwd()}/.ci/settings.xml"
MVN_COMMAND = "${MVN_BASE} --show-version --batch-mode --errors --fail-at-end -DinstallAtEnd=true -DdeployAtEnd=true "
CI = credentials("app-jenkins")
SERVICE_CHECKMARX_URL = credentials("service-checkmarx-url")
SERVICE_SONAR_URL = credentials("service-sonar-url")
SERVICE_GIT_URL = credentials("service-gitlab-url")
SERVICE_INFRA_URL = credentials("service-gitinfra-url")
SERVICE_NEXUS_URL = credentials("service-nexus-url")
SERVICE_PROXY_HOST = credentials("http-proxy-host")
SERVICE_PROXY_PORT = credentials("http-proxy-port")
NOPROXY_HOST = credentials("http_nonProxyHosts")
SERVICE_REPO_SSHURL = credentials("repository-connection-string")
SERVICE_REPOSITORY_URL=credentials("service-repository-url")
JAVA_TOOL_OPTIONS = "-Dhttp.proxyHost=${env.SERVICE_PROXY_HOST} -Dhttp.proxyPort=${env.SERVICE_PROXY_PORT} -Dhttps.proxyHost=${env.SERVICE_PROXY_HOST} -Dhttps.proxyPort=${env.SERVICE_PROXY_PORT} -Dhttp.nonProxyHosts=${env.NOPROXY_HOST}"
}
options {
disableConcurrentBuilds()
buildDiscarder(
logRotator(
artifactDaysToKeepStr: '',
artifactNumToKeepStr: '',
numToKeepStr: '100'
)
)
}
triggers {
cron('45 2 * * *')
}
stages {
stage('Activate steps') {
agent none
steps {
script {
env.DO_TEST = 'true'
env.DO_SECURITY = 'true'
env.DO_BUILD = 'true'
env.DO_PUBLISH = 'true'
}
}
}
stage('Check vulnerabilities and tests.') {
when {
environment(name: 'DO_SECURITY', value: 'true')
}
environment {
PUPPETEER_DOWNLOAD_HOST="${env.SERVICE_NEXUS_URL}/repository/puppeteer-chrome/"
JAVA_TOOL_OPTIONS=""
}
steps {
sh 'npmrc default'
sh '''
$MVN_COMMAND clean verify org.owasp:dependency-check-maven:aggregate -Pvitam -pl '!cots/vitamui-nginx,!cots/vitamui-mongod,!cots/vitamui-logstash,!cots/vitamui-mongo-express' $JAVA_TOOL_OPTIONS
'''
}
post {
always {
junit '**/target/surefire-reports/*.xml'
}
success {
archiveArtifacts (
artifacts: '**/dependency-check-report.html',
fingerprint: true
)
}
}
}
stage('Build sources') {
environment {
PUPPETEER_DOWNLOAD_HOST="${env.SERVICE_NEXUS_URL}/repository/puppeteer-chrome/"
}
when {
environment(name: 'DO_BUILD', value: 'true')
}
steps {
sh 'npmrc default'
sh '''
$MVN_COMMAND deploy -Pvitam,rpm,webpack -DskipTests -DskipAllFrontend=true -Dlicense.skip=true -pl '!cots/vitamui-nginx,!cots/vitamui-mongod,!cots/vitamui-logstash,!cots/vitamui-mongo-express' $JAVA_TOOL_OPTIONS
'''
}
}
stage('Build COTS') {
environment {
http_proxy="http://${env.SERVICE_PROXY_HOST}:${env.SERVICE_PROXY_PORT}"
https_proxy="http://${env.SERVICE_PROXY_HOST}:${env.SERVICE_PROXY_PORT}"
}
when {
environment(name: 'DO_BUILD', value: 'true')
}
steps {
sh 'npmrc internet'
dir('cots/') {
sh '''
$MVN_COMMAND deploy -Pvitam,rpm -DskipTests -Dlicense.skip=true $JAVA_TOOL_OPTIONS
'''
}
}
}
stage("Get publishing scripts") {
when {
environment(name: 'DO_PUBLISH', value: 'true')
environment(name: 'DO_BUILD', value: 'true')
}
steps {
checkout([$class: 'GitSCM',
branches: [[name: 'oshimae']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'vitam-build.git']],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'app-jenkins', url: "$SERVICE_GIT_URL"]]
])
}
}
stage("Publish rpm") {
when {
environment(name: 'DO_PUBLISH', value: 'true')
environment(name: 'DO_BUILD', value: 'true')
}
steps {
sshagent (credentials: ['jenkins_sftp_to_repository']) {
sh 'vitam-build.git/push_vitamui_repo.sh contrib $SERVICE_REPO_SSHURL'
}
}
}
stage("Update symlink") {
when {
anyOf {
branch "develop*"
branch "master_*"
tag pattern: "^[1-9]+\\.[0-9]+\\.[0-9]*+-?[0-9]*\$", comparator: "REGEXP"
}
environment(name: 'DO_PUBLISH', value: 'true')
environment(name: 'DO_BUILD', value: 'true')
}
steps {
sshagent (credentials: ['jenkins_sftp_to_repository']) {
sh 'vitam-build.git/push_symlink_repo.sh contrib $SERVICE_REPO_SSHURL'
}
}
}
stage("Checkmarx analysis") {
when {
anyOf {
branch "develop*"
branch "master_*"
branch "master"
tag pattern: "^[1-9]+\\.[0-9]+\\.[0-9]+-?[0-9]*\$", comparator: "REGEXP"
}
}
environment {
JAVA_TOOL_OPTIONS = ""
}
steps {
sh 'mkdir -p target'
sh 'mkdir -p logs'
// KWA : Visibly, backslash escape hell. \\ => \ in groovy string.
sh '/opt/CxConsole/runCxConsole.sh scan --verbose -Log "${PWD}/logs/cxconsole.log" -CxServer "$SERVICE_CHECKMARX_URL" -CxUser "VITAM openLDAP\\\\$CI_USR" -CxPassword \\"$CI_PSW\\" -ProjectName "CxServer\\SP\\Vitam\\Users\\vitam-ui $GIT_BRANCH" -LocationType folder -locationPath "${PWD}/" -Preset "Default 2014" -LocationPathExclude cots deployment deploymentByVitam docs integration-tests tools -forcescan -ReportPDF "${PWD}/target/checkmarx-report.pdf"'
}
post {
success {
archiveArtifacts (
artifacts: 'target/checkmarx-report.pdf',
fingerprint: true
)
}
failure {
archiveArtifacts (
artifacts: 'logs/cxconsole.log',
fingerprint: true
)
}
}
}
}
}