Skip to content

Commit 18c3eda

Browse files
committed
Jenkins File
1 parent 01d753d commit 18c3eda

File tree

2 files changed

+79
-1
lines changed

2 files changed

+79
-1
lines changed

Jenkins-PIpeline-Demo/Jenkinsfile

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
pipeline {
2+
environment {
3+
registry = "dailycodebuffer/spring-boot-jenkins-docker"
4+
registryCredential = 'dockerhub'
5+
dockerImage = ''
6+
}
7+
agent any
8+
tools { maven "M3" }
9+
stages {
10+
stage('Cloning Git') {
11+
steps {
12+
git 'https://github.com/dailycodebuffer/Spring-MVC-Tutorials.git'
13+
}
14+
}
15+
stage('Build') {
16+
steps {
17+
dir('Jenkins-PIpeline-Demo') {
18+
bat 'mvn -Dmaven.test.failure.ignore clean package'
19+
}
20+
}
21+
}
22+
stage('Test') {
23+
steps {
24+
dir('Jenkins-PIpeline-Demo') {
25+
junit '**/target/surefire-reports/TEST-*.xml'
26+
archiveArtifacts 'target/*.jar'
27+
}
28+
}
29+
}
30+
stage('SonarQube Analysis') {
31+
steps {
32+
dir('Jenkins-PIpeline-Demo') {
33+
withSonarQubeEnv('sonarqube') {
34+
bat 'mvn sonar:sonar'
35+
}
36+
}
37+
}
38+
}
39+
stage('Building image') {
40+
steps{
41+
script {
42+
dir('Jenkins-PIpeline-Demo') {
43+
dockerImage = docker.build registry + ":$BUILD_NUMBER"
44+
}
45+
}
46+
}
47+
}
48+
stage('Deploy Image') {
49+
steps{
50+
script {
51+
dir('Jenkins-PIpeline-Demo') {
52+
docker.withRegistry( '', registryCredential ) {
53+
dockerImage.push()
54+
}
55+
}
56+
}
57+
}
58+
}
59+
stage('Remove Unused docker image') {
60+
steps{
61+
dir('Jenkins-PIpeline-Demo') {
62+
bat "docker rmi $registry:$BUILD_NUMBER"
63+
}
64+
}
65+
}
66+
}
67+
68+
post {
69+
70+
success {
71+
echo 'This Build is Successfull!'
72+
}
73+
failure {
74+
echo 'I failed :('
75+
}
76+
77+
}
78+
}

Jenkins-PIpeline-Demo/src/main/resources/templates/error.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ <h1>Error Occurred!</h1>
77
<span th:text="${error}">error</span>
88
</b>
99
<p th:text="${message}">message</p>
10-
</body>
10+
</body>
1111
</html>

0 commit comments

Comments
 (0)