forked from RaghavGeek/SpringBoot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
59 lines (55 loc) · 1.57 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
57
58
59
pipeline {
agent any
tools {
maven 'Maven'
}
environment {
registry = "prabhat2020/testing4"
registryCredential = "06216ef3-ad77-49a6-a37b-e2e91cd08bfb"
}
stages {
stage('Initialize'){
steps{
echo "We are doing some test"
echo "PATH = ${PATH}"
}
}
stage('Build'){
steps
{
sh "mvn clean install"
}
}
stage('Sonar'){
steps
{
sh "mvn sonar:sonar -Dsonar.projectKey=SpringPipeline -Dsonar.host.url=http://52.143.7.186/prabhat-sonarqube -Dsonar.login=0144fc0a3377b5a9fd3802be5bdf248a9b0067ae"
}
}
stage('Building our image') {
steps {
script {
dockerImage = docker.build registry
}
}
}
stage('Deploy our image') {
steps {
script {
docker.withRegistry( '', registryCredential ) {
dockerImage.push()
}
}
}
}
stage('Deploy Application on K8s') {
steps
{
sh("curl -LO https://storage.googleapis.com/kubernetes-release/release/\$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl")
sh("chmod +x ./kubectl")
sh("cat ./spring.yaml | ./kubectl apply -f -")
echo "Application started on port: HTTP_PORT (http)"
}
}
}
}