Skip to content

Instantly share code, notes, and snippets.

@bharathirajatut
Last active July 1, 2022 05:08
Show Gist options
  • Save bharathirajatut/1ea62f422588d4c3db6f214d7c5fc1cd to your computer and use it in GitHub Desktop.
Save bharathirajatut/1ea62f422588d4c3db6f214d7c5fc1cd to your computer and use it in GitHub Desktop.
pipeline{
agent any
environment {
DOCKERHUB_CREDENTIALS=credentials('dockerhub-cred-raja')
}
stages {
stage('Build') {
steps {
sh 'docker build -t bharathirajatut/erp:1.0 .'
}
}
stage('Login') {
steps {
sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin'
}
}
stage('Push') {
steps {
sh 'docker push bharathirajatut/erp:1.0'
}
}
stage('Deploy to K8s')
{
steps{
sshagent(['k8s-jenkins'])
{
sh 'scp -r -o StrictHostKeyChecking=no node-deployment.yaml [email protected]:/path'
script{
try{
sh 'ssh [email protected] kubectl apply -f /path/node-deployment.yaml --kubeconfig=/path/kube.yaml'
}catch(error)
{
}
}
}
}
}
}
post {
always {
sh 'docker logout'
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment