-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
56 lines (55 loc) · 2.14 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
@Library('github.com/connexta/cx-pipeline-library@master') _
pipeline {
agent { label 'linux-small' }
options {
buildDiscarder(logRotator(numToKeepStr:'25'))
disableConcurrentBuilds()
timestamps()
skipDefaultCheckout()
}
environment {
MVN_OPTS = '-Xmx1024M -Xss128M '
LINUX_MVN_RANDOM = '-Djava.security.egd=file:/dev/./urandom'
}
stages {
stage('SetUp') {
steps {
dockerd {}
}
}
stage('Build') {
steps {
retry(3) {
checkout scm
}
timeout(time: 20, unit: 'MINUTES') {
withMaven(maven: 'maven-latest', jdk: 'jdk17', globalMavenSettingsConfig: 'default-global-settings', mavenSettingsConfig: 'codice-maven-settings', mavenOpts: '${MVN_OPTS} ${LINUX_MVN_RANDOM}') {
sh 'mvn clean install'
}
}
}
}
/*
Deploy stage will only be executed for deployable branches. These include main and any patch branch matching M.m.x format (i.e. 2.10.x, 2.9.x, etc...).
It will also only deploy in the presence of an environment variable JENKINS_ENV = 'prod'. This can be passed in globally from the jenkins master node settings.
*/
stage('Deploy') {
when {
allOf {
expression { env.CHANGE_ID == null }
expression { env.BRANCH_NAME ==~ /((?:\d*\.)?\d*\.x|main)/ }
environment name: 'JENKINS_ENV', value: 'prod'
}
}
environment {
DOCKER_LOGIN = credentials('dockerhub-codicebot')
}
steps{
sh 'docker login -u $DOCKER_LOGIN_USR -p $DOCKER_LOGIN_PSW'
withMaven(maven: 'maven-latest', jdk: 'jdk17', globalMavenSettingsConfig: 'default-global-settings', mavenSettingsConfig: 'codice-maven-settings', mavenOpts: '${LINUX_MVN_RANDOM}') {
sh 'mvn deploy -DskipTests=true'
}
}
}
}
}