This commit is contained in:
Gregory Hendrickson
2023-06-09 14:35:44 -07:00
parent 83d45cf3a6
commit 6c0d797e27

25
Jenkinsfile vendored
View File

@@ -1,49 +1,35 @@
pipeline { pipeline {
agent any agent any
environment { environment {
DOCKERHUB_CREDENTIALS = credentials('dockerhub-cred') DOCKERHUB_CREDENTIALS = credentials('dockerhub-cred')
} }
stages { stages {
stage('Build') { stage('Build') {
steps { steps {
sh 'docker build -t aisthanestha/docker-test-image:latest .' sh 'docker build -t aisthanestha/docker-test-image:latest .'
} }
} }
stage('Login') { stage('Login') {
steps { steps {
sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin' sh "echo '\$DOCKERHUB_CREDENTIALS_PSW' | docker login -u '\$DOCKERHUB_CREDENTIALS_USR' --password-stdin"
} }
} }
stage('Push') { stage('Push') {
steps { steps {
sh 'docker push aisthanestha/docker-test-image:latest' sh 'docker push aisthanestha/docker-test-image:latest'
} }
} }
// stage('Deploy') { stage('Pull and Deploy') {
// steps {
// // Deploy to remote Docker host
// sshagent(['ssh_creds']) {
// sh "ssh -o StrictHostKeyChecking=accept-new administrator@172.16.11.90 'docker stop --name docker-test-image && docker pull aisthanestha/docker-test-image:latest && docker run -d -p 8082:80 --name docker-test-image:latest'"
// }
// }
// }
// }
stage('Pull and Deploy')
steps { steps {
// Send commands to remote Docker host via SSH
script { script {
sshCommand remote: [ sshCommand remote: [
credentialsId: 'SSH_CREDENTIALS', credentialsId: 'SSH_CREDENTIALS',
host: '172.16.11.90', host: '172.16.11.90',
username: '172.16.11.90' username: 'administrator'
], command: ''' ], command: '''
docker pull aisthanestha/docker-test-image:latest docker pull aisthanestha/docker-test-image:latest
docker stop docker-test-image docker stop docker-test-image
@@ -52,6 +38,8 @@ pipeline{
''' '''
} }
} }
}
}
post { post {
always { always {
@@ -59,4 +47,3 @@ pipeline{
} }
} }
} }