Docker Pipeline and readme

This commit is contained in:
2026-04-15 10:57:25 +02:00
parent 95c277d7df
commit 379155e012
2 changed files with 14 additions and 6 deletions

View File

@@ -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"
}
}

View File

@@ -79,3 +79,8 @@ Step 4: Push your image to the Docker hub
docker push yourhubusername/verse_gapminder:firsttry
```
## License
This repository is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License (CC BY-SA 4.0).
For details, see https://creativecommons.org/licenses/by-sa/4.0/.