Select Git revision
Jenkinsfile
-
Vinod Bangera authoredVinod Bangera authored
Jenkinsfile 2.89 KiB
pipeline {
agent any
// tools {
// nodejs 'NodeJS'
// }
environment {
PROJECT_ID = "tech-rnd-project"
CLUSTER_NAME = "python-cluster"
LOCATION = "us-central1-a"
CREDENTIALS_ID = "335fefa0-0089-4fe2-994c-fd3bd9e2ab2b"
}
stages {
stage('Scm Checkout') {
steps {
checkout scm
}
}
stage('Build') {
steps {
echo 'building the software'
// sh 'npm install --force'
}
}
stage('Test') {
steps {
//add steps here
echo 'testing'
}
}
stage('Build Docker Image') {
steps {
script {
sh 'whoami'
sh 'sudo chmod 777 /var/run/docker.sock'
sh "docker build -t python-postgress ."
}
}
}
// stage('Image Scan') {
// steps {
// //add steps here
// echo 'image scanning'
// sh 'trivy image --no-progress --exit-code 1 --severity CRITICAL python-postgress'
// }
// }
stage('Push Docker Image') {
steps {
script {
echo 'Push Docker Image'
sh "docker tag python-postgress asia-south1-docker.pkg.dev/tech-rnd-project/container-python/python"
sh 'gcloud auth configure-docker asia-south1-docker.pkg.dev'
sh 'docker push asia-south1-docker.pkg.dev/tech-rnd-project/container-python/python'
// 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 "sudo mv kubectl \$(which kubectl)"
}
}
}
stage('Deploy to K8s') {
steps {
echo 'Deployment started ...'
sh 'ls -ltr'
sh 'pwd'
echo 'Start deployment of deployment.yaml'
step([$class: 'KubernetesEngineBuilder', projectId: env.PROJECT_ID, clusterName: env.CLUSTER_NAME, location: env.LOCATION, manifestPattern: 'k8', credentialsId: env.CREDENTIALS_ID, verifyDeployments: true])
echo 'Deployment Finished ...'
sh '''
'''
}
}
}
post {
always {
emailext to: 'vinod.bangera@niveussolutions.com',
subject: "jenkins build:${currentBuild.currentResult}: ${env.JOB_NAME}",
body: "${currentBuild.currentResult}: Job ${env.JOB_NAME}\nMore Info can be found in the attached log",
attachLog: true
}
}
}