mirror of
https://github.com/ghndrx/docker-test-image.git
synced 2026-02-10 14:55:14 +00:00
s
This commit is contained in:
25
Jenkinsfile
vendored
25
Jenkinsfile
vendored
@@ -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{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user