Commit c1ff6dae authored by Ishtiaq Ahmed's avatar Ishtiaq Ahmed

Update Jenkinsfile

parent cf41d93e
pipeline { pipeline {
agent any
environment {
PROJECT_ID = 'secret-lambda-365807'
CLUSTER_NAME = 'cicd-task'
LOCATION = 'us-central1-c'
CREDENTIALS_ID = 'k8s-cicd'
}
tools {
maven 'Maven'
}
stages { stages {
stage("Cloning Code- GitLab") { stage("Cloning Code- GitLab") {
steps { steps {
script { script {
echo "cloning Code from GitLab" echo "cloning Code from GitLab"
//sh "rm -rf *"
git branch: 'master', url: 'https://gitlab.mynisum.com/isahmed/nisum-cicd-task.git'
} }
} }
} }
stage("Code Build") {
steps {
script {
echo "Building application from code"
sh 'mvn clean package'
sh 'mvn package'
}
}
}
stage("Image Build & Push") {
steps {
script {
echo "building application"
withCredentials([usernamePassword(credentialsId: 'gitlab-ishtiaq', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
sh "sed -i 's/VERSION/${env.BUILD_ID}/g' docker-build.sh"
sh 'chmod +x docker-build.sh'
sh './docker-build.sh'
}
}
}
}
stage("Deployment on GKE") {
steps {
sh "sed -i 's/VERSION/${env.BUILD_ID}/g' dep-nisum-cicd.yaml"
step([$class: 'KubernetesEngineBuilder', \
projectId: env.PROJECT_ID, \
clusterName: env.CLUSTER_NAME, \
location: env.LOCATION, \
manifestPattern: 'dep-nisum-cicd.yaml', \
credentialsId: env.CREDENTIALS_ID, \
verifyDeployments: true])
}
}
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment