jenkins-wdocker/Jenkinsfile

40 lines
863 B
Plaintext
Raw Normal View History

2019-06-20 13:03:21 -04:00
pipeline {
environment {
2019-06-25 18:29:34 -04:00
registry = 'https://registry.hub.docker.com'
2019-06-20 13:03:21 -04:00
registryCredential = 'dockerhub_jcabillot'
2019-06-25 18:29:34 -04:00
dockerImage = 'jcabillot/jenkins-wdocker'
2023-02-21 14:44:33 -05:00
DOCKER_BUILDKIT = '1'
2019-06-20 13:03:21 -04:00
}
2019-06-25 18:31:11 -04:00
agent any
2019-07-03 17:47:15 -04:00
triggers {
2019-07-03 17:51:10 -04:00
cron('@midnight')
2019-07-03 17:47:15 -04:00
}
2019-06-20 13:03:21 -04:00
stages {
2019-06-25 18:16:53 -04:00
stage('Clone repository') {
2019-06-25 18:19:19 -04:00
steps{
2019-06-25 18:16:53 -04:00
checkout scm
2019-06-25 18:19:19 -04:00
}
2019-06-20 13:03:21 -04:00
}
2019-06-25 18:16:53 -04:00
stage('Build image') {
2019-06-25 18:19:19 -04:00
steps{
2020-01-08 13:52:26 -05:00
sh 'docker build --force-rm=true --no-cache=true --pull -t ${dockerImage} .'
2019-06-25 18:19:19 -04:00
}
2019-06-25 18:16:53 -04:00
}
2019-06-20 13:03:21 -04:00
stage('Deploy Image') {
steps{
script {
2019-06-26 19:12:52 -04:00
withCredentials([usernamePassword(credentialsId: 'dockerhub_jcabillot', usernameVariable: 'DOCKER_USER', passwordVariable: 'DOCKER_PASS')]) {
2019-06-26 19:16:21 -04:00
sh 'docker login --username ${DOCKER_USER} --password ${DOCKER_PASS}'
sh 'docker push ${dockerImage}'
}
2019-06-20 13:03:21 -04:00
}
}
}
}
}