Add preflight checks in Jenkinsfile to ensure Docker is installed on the agent before proceeding with the pipeline, improving error handling and setup validation.
This commit is contained in:
19
Jenkinsfile
vendored
19
Jenkinsfile
vendored
@@ -1,5 +1,7 @@
|
||||
pipeline {
|
||||
agent any
|
||||
agent {
|
||||
label 'any'
|
||||
}
|
||||
|
||||
options {
|
||||
timestamps()
|
||||
@@ -17,6 +19,21 @@ pipeline {
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Preflight tools') {
|
||||
steps {
|
||||
sh '''
|
||||
set -euo pipefail
|
||||
echo "Node: $(hostname)"
|
||||
if ! command -v docker >/dev/null 2>&1; then
|
||||
echo "ERROR: este agente no tiene docker instalado."
|
||||
echo "Usa un nodo Jenkins con label 'docker' y acceso al daemon."
|
||||
exit 1
|
||||
fi
|
||||
docker --version
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
checkout([
|
||||
|
||||
Reference in New Issue
Block a user