-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
49 lines (46 loc) · 1.58 KB
/
Jenkinsfile
File metadata and controls
49 lines (46 loc) · 1.58 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
pipeline {
agent any
environment {
// Define any environment variables needed for the pipeline
IMAGE_NAME = 'microservice1-auth'
CONTAINER_NAME = 'microservice1-auth-container'
DOCKERHUB_CREDENTIALS = credentials('dockerhub_amina')
PROJECT_ID = 'igneous-clover-409614'
CLUSTER_NAME = 'cluster-2'
LOCATION = 'us-central1-c'
CREDENTIALS_ID = 'gke_cluster'
}
stages {
stage('Build') {
steps {
script {
echo 'Building...'
sh 'mvn clean compile package -DskipTests'
}
}
}
stage('Dockerize') {
steps {
script {
echo 'Dockerizing...'
sh "docker build -t aminabakkali/${IMAGE_NAME} ."
}
}
}
stage('Login + Push') {
steps {
echo 'Login...'
sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin'
echo 'Pushing...'
sh "docker push aminabakkali/${IMAGE_NAME}"
}
}
stage('Deploy to GKE') {
steps{
echo 'Deploying...'
step([$class: 'KubernetesEngineBuilder', projectId: env.PROJECT_ID, clusterName: env.CLUSTER_NAME, location: env.LOCATION, manifestPattern: 'microservice1-auth.yaml', credentialsId: env.CREDENTIALS_ID, verifyDeployments: true])
echo "Deployment finished !"
}
}
}
}