From 9dd7d2ca732c668eb6ae58c3d20b27e4ff2c9e6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20V=C3=A1squez?= Date: Wed, 29 Oct 2025 16:00:07 -0300 Subject: [PATCH] update --- Jenkinsfile | 73 ++++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 55d1d56..e10b79b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,53 +1,52 @@ pipeline { - agent any + agent any - stages { - stage('Checkout') { - steps { - checkout scm - } - } + stages { + stage('Checkout') { + steps { + checkout scm + } + } - stage('Build Image') { - steps { - echo 'Building image...' - // --pull ensures base layer is fresh; tag includes BUILD_NUMBER to avoid cache clashes - sh 'docker build --pull -t my-python-app:${BUILD_NUMBER} .' - } - } + stage('Build Image') { + steps { + echo 'Building image...' + // --pull ensures base layer is fresh; tag includes BUILD_NUMBER to avoid cache clashes + sh 'docker build --pull -t my-python-app:${BUILD_NUMBER} .' + } + } - stage('Run Container') { - steps { - echo 'Running container...' - // --rm cleans up; this will print "Hello, World!" to the console - sh 'docker run --rm --name my-python-app-${BUILD_NUMBER} my-python-app:${BUILD_NUMBER}' - } - } + stage('Run Container') { + steps { + echo 'Running container...' + // --rm cleans up; this will print "Hello, World!" to the console + sh 'docker run --rm --name my-python-app-${BUILD_NUMBER} my-python-app:${BUILD_NUMBER}' + } + } - stage('(Optional) Verify Output') { - steps { - script { - // Re-run capturing output to assert expected behavior (example) - def out = sh( + stage('(Optional) Verify Output') { + steps { + script { + // Re-run capturing output to assert expected behavior (example) + def out = sh( script: 'docker run --rm my-python-app:${BUILD_NUMBER}', returnStdout: true ).trim() - if (out != 'Hello, World!') { - error "Unexpected output: '${out}'" - } + if (out != 'Hello, World!') { + error "Unexpected output: '${out}'" + } + } + } } - } } - } - post { - always { - // Best-effort cleanup of any leftover container/image for this build tag - sh ''' + post { + always { + // Best-effort cleanup of any leftover container/image for this build tag + sh ''' docker rm -f my-python-app-${BUILD_NUMBER} 2>/dev/null || true docker image rm my-python-app:${BUILD_NUMBER} 2>/dev/null || true ''' + } } - } } -``