-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
54 lines (49 loc) · 1.62 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
pipeline {
agent any
tools {
maven 'Maven'
}
environment {
registry = "raghavgeek/testing"
registryCredential = "8acfc31c-d902-463d-ad29-afdc446892df"
}
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/sonarqube-1336430 -Dsonar.login=23e2ff1beac97da72a5edff2c7e3a72e33578244"
}
}
stage('Building/Deploying our image') {
steps
{
withCredentials([usernamePassword(credentialsId: '8acfc31c-d902-463d-ad29-afdc446892df', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh ("docker login -u ${USERNAME} -p ${PASSWORD}")
sh ("docker build -t ${USERNAME}/testing:first .")
sh ("docker push ${USERNAME}/testing:first")
}
}
}
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)"
}
}
}
}