mirror of
https://github.com/ghndrx/docker-test-image.git
synced 2026-02-10 14:55:14 +00:00
with cred
This commit is contained in:
41
Jenkinsfile
vendored
41
Jenkinsfile
vendored
@@ -2,7 +2,6 @@ pipeline {
|
|||||||
agent any
|
agent any
|
||||||
environment {
|
environment {
|
||||||
DOCKERHUB_CREDENTIALS=credentials('dockerhub-cred')
|
DOCKERHUB_CREDENTIALS=credentials('dockerhub-cred')
|
||||||
SSH_CREDENTIALS=credentials('ssh-cred')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
@@ -26,30 +25,34 @@ pipeline {
|
|||||||
|
|
||||||
stage('Pull and Deploy') {
|
stage('Pull and Deploy') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
withCredentials([
|
||||||
def remote = [:]
|
usernamePassword(credentialsId: 'ssh-cred', usernameVariable: 'SSH_USER', passwordVariable: 'SSH_PASSWORD')
|
||||||
remote.name = 'ubuntu-kc'
|
]) {
|
||||||
remote.host = '172.16.11.90'
|
script {
|
||||||
remote.user = "greg"
|
def remote = [:]
|
||||||
remote.password = "Password1!"
|
remote.name = 'ubuntu-kc'
|
||||||
remote.allowAnyHosts = true
|
remote.host = '172.16.11.90'
|
||||||
|
remote.user = "${SSH_USER}"
|
||||||
|
remote.password = "${SSH_PASSWORD}"
|
||||||
|
remote.allowAnyHosts = true
|
||||||
|
|
||||||
writeFile file: 'run-pull-deploy.sh', text: '''
|
writeFile file: 'run-pull-deploy.sh', text: '''
|
||||||
docker pull aisthanestha/docker-test-image:latest
|
docker pull aisthanestha/docker-test-image:latest
|
||||||
docker stop docker-test-image
|
docker stop docker-test-image
|
||||||
docker rm docker-test-image
|
docker rm docker-test-image
|
||||||
docker run -d --name docker-test-image -p 8082:80 aisthanestha/docker-test-image:latest
|
docker run -d --name docker-test-image -p 8082:80 aisthanestha/docker-test-image:latest
|
||||||
'''
|
'''
|
||||||
|
|
||||||
// Transfer the script file to the remote host
|
// Transfer the script file to the remote host
|
||||||
sshPut remote: remote, from: 'run-pull-deploy.sh', into: 'run-pull-deploy.sh'
|
sshPut remote: remote, from: 'run-pull-deploy.sh', into: 'run-pull-deploy.sh'
|
||||||
|
|
||||||
// Execute the script file on the remote host
|
// Execute the script file on the remote host
|
||||||
sshCommand remote: remote, command: 'chmod +x run-pull-deploy.sh && ./run-pull-deploy.sh'
|
sshCommand remote: remote, command: 'chmod +x run-pull-deploy.sh && ./run-pull-deploy.sh'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
post {
|
post {
|
||||||
always {
|
always {
|
||||||
|
|||||||
Reference in New Issue
Block a user