Docker Pipeline and readme
This commit is contained in:
@@ -8,15 +8,18 @@ pipeline {
|
||||
}
|
||||
}
|
||||
environment {
|
||||
// Executem una comanda shell per obtenir la data actual i la guardem com a variable
|
||||
DATA = sh(returnStdout: true, script: 'date +%Y-%m-%d').trim()
|
||||
DOCKER_HUB_USER='guillemhs'
|
||||
IMAGE_NAME="${DOCKER_HUB_USER}/the-example-app-20260413"
|
||||
IMAGE_NAME="${DOCKER_HUB_USER}/the-example-app-nodejs"
|
||||
REGISTRY_CRED_ID='docker-credentials'
|
||||
TAG="${DATA}-${env.BUILD_NUMBER}"
|
||||
}
|
||||
stages {
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
// Get some code from a GIT repository
|
||||
git 'https://git.agile611.com/Agile611/the-example-app-nodejs.git'
|
||||
// Get some code from the sane repository
|
||||
checkout scm
|
||||
}
|
||||
}
|
||||
stage('Docker Build') {
|
||||
@@ -32,10 +35,10 @@ pipeline {
|
||||
steps{
|
||||
script{
|
||||
docker.withRegistry('',REGISTRY_CRED_ID){
|
||||
def app = docker.image("${IMAGE_NAME}:${env.BUILD_NUMBER}")
|
||||
def app = docker.image("${IMAGE_NAME}:${TAG}")
|
||||
|
||||
echo "Pushing image to Docker Hub ..."
|
||||
app.push("${env.BUILD_NUMBER}")
|
||||
app.push("${TAG}")
|
||||
app.push("latest")
|
||||
}
|
||||
}
|
||||
@@ -45,7 +48,7 @@ pipeline {
|
||||
post{
|
||||
always{
|
||||
cleanWs()
|
||||
sh "docker rmi ${IMAGE_NAME}:${env.BUILD_NUMBER} || true"
|
||||
sh "docker rmi ${TAG} || true"
|
||||
sh "docker rmi ${IMAGE_NAME}:latest || true"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user