fix:加入健康检查
This commit is contained in:
Vendored
+15
-11
@@ -58,21 +58,25 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Run Docker Container') {
|
stage('Check Docker Status') {
|
||||||
agent any
|
agent any
|
||||||
steps {
|
steps {
|
||||||
sh '''
|
script {
|
||||||
docker rm -f $CONTAINER_NAME || true
|
timeout(time: 60, unit: 'SECONDS') {
|
||||||
docker run -d --name $CONTAINER_NAME \\
|
waitUntil {
|
||||||
-p $HOST_PORT:$CONTAINER_PORT \\
|
def status = sh(
|
||||||
--health-cmd="curl -f http://localhost:$CONTAINER_PORT || exit 1" \\
|
script: "docker inspect -f '{{.State.Health.Status}}' $CONTAINER_NAME || echo 'no-healthcheck'",
|
||||||
--health-interval=10s \\
|
returnStdout: true
|
||||||
--health-timeout=5s \\
|
).trim()
|
||||||
--health-retries=3 \\
|
echo "Current container status: ${status}"
|
||||||
$IMAGE_NAME
|
return (status == 'healthy')
|
||||||
'''
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user