diff --git a/DockerPipelinePluginJenkinsfile b/DockerPipelinePluginJenkinsfile index c4be554..86937b4 100644 --- a/DockerPipelinePluginJenkinsfile +++ b/DockerPipelinePluginJenkinsfile @@ -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" } } diff --git a/README.md b/README.md index 97db134..39079be 100644 --- a/README.md +++ b/README.md @@ -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/. +