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:
98
Jenkinsfile
vendored
98
Jenkinsfile
vendored
@@ -1,57 +1,59 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
environment {
|
environment {
|
||||||
DOCKERHUB_CREDENTIALS=credentials('dockerhub-cred')
|
DOCKERHUB_CREDENTIALS=credentials('dockerhub-cred')
|
||||||
SSH_CREDENTIALS=credentials('SSH-CREDENTIALS')
|
SSH_CREDENTIALS=credentials('SSH-CREDENTIALS')
|
||||||
}
|
}
|
||||||
|
|
||||||
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('Pull and Deploy') {
|
|
||||||
steps {
|
|
||||||
node('any') {
|
|
||||||
def remote = [:]
|
|
||||||
remote.name = 'ubuntu-kc'
|
|
||||||
remote.host = '172.16.11.90'
|
|
||||||
remote.user = 'greg'
|
|
||||||
remote.password = 'Password1!'
|
|
||||||
remote.allowAnyHosts = true
|
|
||||||
// Provide a label for the Jenkins agent
|
|
||||||
writeFile file: 'run-pull-deploy.sh', text: '''docker pull aisthanestha/docker-test-image:latest &&
|
|
||||||
docker stop docker-test-image &&
|
|
||||||
docker rm docker-test-image &&
|
|
||||||
docker run -d --name docker-test-image aisthanestha/docker-test-image:latest'''
|
|
||||||
sshScript remote: remote, script: 'run-pull-deploy.sh'
|
|
||||||
|
|
||||||
}
|
stage('Pull and Deploy') {
|
||||||
}
|
steps {
|
||||||
}
|
script {
|
||||||
|
def remote = [:]
|
||||||
|
remote.name = 'ubuntu-kc'
|
||||||
|
remote.host = '172.16.11.90'
|
||||||
|
remote.user = 'greg'
|
||||||
|
remote.password = 'Password1!'
|
||||||
|
remote.allowAnyHosts = true
|
||||||
|
|
||||||
}
|
writeFile file: 'run-pull-deploy.sh', text: '''
|
||||||
}
|
docker pull aisthanestha/docker-test-image:latest
|
||||||
|
docker stop docker-test-image
|
||||||
|
docker rm docker-test-image
|
||||||
|
docker run -d --name docker-test-image aisthanestha/docker-test-image:latest
|
||||||
|
'''
|
||||||
|
|
||||||
post {
|
node('any') {
|
||||||
always {
|
sshScript remote: remote, script: 'run-pull-deploy.sh'
|
||||||
node('any'){
|
}
|
||||||
sh 'docker logout'
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
node('any') {
|
||||||
|
sh 'docker logout'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user