-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile.groovy.RENAME-B
60 lines (57 loc) · 1.97 KB
/
Jenkinsfile.groovy.RENAME-B
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
60
pipeline {
agent any
environment {
PROJECT_ID = 'bold-physics-383802'
CLUSTER_NAME = 'cluster-1'
LOCATION = 'us-central1-c'
CREDENTIALS_ID = 'bold-physics-383802'
}
tools {
// Install the Maven version configured as "M3" and add it to the path.
maven "maven"
}
stages {
stage('SonarQube Analysis') {
steps {
sh 'sonar-scanner \
-Dsonar.host.url=http://10.0.0.77:9000/ \
-Dsonar.login=$SQ_Token \
-Dsonar.projectKey=my-web-app \
-Dsonar.sources=. \
-Dsonar.java.binaries=.'
}
}
stage('GIT CHECKOUT') {
steps {
// Get some code from a GitHub repository
git branch: 'main', url: 'https://github.com/apotitech/Hello-Node.git'
}
}
stage('MAVEN BUILD') {
steps {
// Get some code from a GitHub repository
sh "mvn clean install package"
}
}
stage('DOCKER BUILD') {
steps {
// Get some code from a GitHub repository
sh "docker build -t apotieri/app_maven_001 ."
}
}
stage('DOCKER PUSH') {
steps {
withCredentials([usernamePassword(credentialsId: 'docker', passwordVariable: 'pwd', usernameVariable: 'user')]) {
sh "docker login -u ${user} -p ${pwd}"
sh "docker push apotieri/app_maven_001"
}
}
}
stage('Deploy to kubernetes'){
steps{
step([$class: 'KubernetesEngineBuilder', projectId: env.PROJECT_ID, clusterName: env.CLUSTER_NAME, location: env.LOCATION, manifestPattern: 'petclinic.yaml', credentialsId: env.CREDENTIALS_ID, verifyDeployments: true])
echo "Deployment Finished ..."
}
}
}
}