Last active
July 1, 2022 05:08
-
-
Save bharathirajatut/1ea62f422588d4c3db6f214d7c5fc1cd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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