forked from keeplearningandtrying/devzone
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfileInline
More file actions
59 lines (53 loc) · 2.38 KB
/
JenkinsfileInline
File metadata and controls
59 lines (53 loc) · 2.38 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
53
54
55
56
57
58
59
#!groovy
def DOCKER_USERNAME = 'sivaprasadreddy'
def DOCKER_IMAGE_NAME = 'devzone-slim'
node {
try {
stage('Checkout') {
checkout([$class: 'GitSCM', branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [],
userRemoteConfigs: [[url: 'https://github.com/sivaprasadreddy/devzone.git']]])
}
stage('Build') {
try {
sh './gradlew clean build'
} finally {
junit allowEmptyResults: true, testResults: 'target/test-results/test/*.xml'
junit allowEmptyResults: true, testResults: 'target/test-results/integrationTest/*.xml'
publishHTML(target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : 'target/jacoco/test',
reportFiles : 'index.html',
reportName : "Jacoco Unit Test Report"
])
publishHTML(target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : 'target/jacoco/integrationTest',
reportFiles : 'index.html',
reportName : "Jacoco Integration Test Report"
])
}
}
stage('Publish Docker Image') {
sh "./gradlew bootBuildImage -Dspring-boot.build-image.imageName=${DOCKER_USERNAME}/${DOCKER_IMAGE_NAME}:${env.BUILD_NUMBER}"
if(env.BRANCH_NAME == 'master' || env.BRANCH_NAME == 'main') {
echo "Publishing to dockerhub DOCKER_USERNAME=${DOCKER_USERNAME}, APPLICATION_NAME=${DOCKER_IMAGE_NAME}"
withDockerRegistry(credentialsId: 'dockerhub-credentials') {
def appImage = docker.build("${DOCKER_USERNAME}/${DOCKER_IMAGE_NAME}:${env.BUILD_NUMBER}")
appImage.push()
appImage.push('latest')
}
} else {
echo "Skipping Publish Docker Image"
}
}
}
catch(err) {
echo "ERROR: ${err}"
currentBuild.result = currentBuild.result ?: "FAILURE"
}
}