forked from g0t4/jenkins2-course-spring-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
53 lines (47 loc) · 2.35 KB
/
Jenkinsfile
File metadata and controls
53 lines (47 loc) · 2.35 KB
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
node('master'){
stage('Checkout'){
git 'https://integration.pl.s2-eu.capgemini.com/gerrit/XTech-WebApp.git'
}
stage('Build Step'){
withMaven(
//configFileProvider(
//[configFile(fileId: '9a5b5c87-1231-4fef-9b32-d90713ac0587', variable: 'MySettings')]))
// Maven installation declared in the Jenkins "Global Tool Configuration"
maven: 'Maven3', mavenSettingsFilePath: 'settings.xml',
// Maven settings.xml file defined with the Jenkins Config File Provider Plugin
// Maven settings and global settings can also be defined in Jenkins Global Tools Configuration
//mavenSettingsConfig: '9a5b5c87-1231-4fef-9b32-d90713ac0587:MySettings',
mavenLocalRepo: '.repository'){
properties([gitLabConnection(''), parameters([string(defaultValue: '5.6.7', description: '', name: 'XTECHDEMO_VERSION_NUMBER', trim: false)])])
sh 'echo ${XTECHDEMO_VERSION_NUMBER}'
// Run the maven build
sh 'mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent versions:set -DnewVersion=${XTECHDEMO_VERSION_NUMBER}.${BUILD_NUMBER} deploy'
}
}
stage ('Junit Results') {
junit testResults: '**/target/surefire-reports/*.xml'
}
stage('SonarQube analysis'){
withSonarQubeEnv('SONARQUBE'){
// requires SonarQube Scanner for Maven 3.2+
withMaven(
// Maven installation declared in the Jenkins "Global Tool Configuration"
maven: 'Maven3',
// Maven settings.xml file defined with the Jenkins Config File Provider Plugin
// Maven settings and global settings can also be defined in Jenkins Global Tools Configuration
//mavenSettingsConfig: 'my-maven-settings',
mavenLocalRepo: '.repository'){
sh 'mvn sonar:sonar -Dsonar.host.url=http://sonarqube-core:9000/sonarqube -Dsonar.login=cf8720cec372872e1d36a72c3eb786d6d13c5379 -Dsonar.java.coveragePlugin=jacoco -Dsonar.jacoco.reportPaths=target/jacoco.exec'
}
}
}
}
node('slave'){
stage('Build docker image'){
sh 'whoami'
sh 'cd /data/jenkins/workspace/PipelineJob'
sh 'docker build -t docker-registry-integration.pl.s2-eu.capgemini.com/testimage:v1 .'
//sh 'docker push docker-registry-integration.pl.s2-eu.capgemini.com/testimage:v1'
sh 'docker run -d docker-registry-integration.pl.s2-eu.capgemini.com/testimage:v1'
}
}