diff --git a/Jenkinsfile b/Jenkinsfile index 54b0df9..a54e357 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -58,21 +58,25 @@ pipeline { } } - stage('Run Docker Container') { + stage('Check Docker Status') { agent any steps { - sh ''' - docker rm -f $CONTAINER_NAME || true - docker run -d --name $CONTAINER_NAME \\ - -p $HOST_PORT:$CONTAINER_PORT \\ - --health-cmd="curl -f http://localhost:$CONTAINER_PORT || exit 1" \\ - --health-interval=10s \\ - --health-timeout=5s \\ - --health-retries=3 \\ - $IMAGE_NAME - ''' + script { + timeout(time: 60, unit: 'SECONDS') { + waitUntil { + def status = sh( + script: "docker inspect -f '{{.State.Health.Status}}' $CONTAINER_NAME || echo 'no-healthcheck'", + returnStdout: true + ).trim() + echo "Current container status: ${status}" + return (status == 'healthy') + } } } + } +} + + } }