diff --git a/Jenkinsfile b/Jenkinsfile index 82d9fd7..eb824e1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -52,6 +52,7 @@ pipeline { sh ''' docker rm -f $CONTAINER_NAME || true docker run -d --name $CONTAINER_NAME \\ + --network mysql_default \\ -p $HOST_PORT:$CONTAINER_PORT \\ --health-cmd="curl -f http://localhost:80 || exit 1" \\ --health-interval=5s \\ @@ -65,21 +66,24 @@ pipeline { agent any steps { script { + def lastStatus = '' 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') + script: "docker inspect -f '{{.State.Health.Status}}' $CONTAINER_NAME || echo 'no-healthcheck'", + returnStdout: true + ).trim() + + if (status != lastStatus) { + echo "Container health: ${status}" + lastStatus = status + } + + return (status == 'healthy') + } + } } } } } } - - - - } -}