Skrypt Tworzący wolumen apps-data jeśli nie ma

This commit is contained in:
Artur 2024-12-19 23:58:32 +01:00
parent a2c1237d85
commit b1e3b38958
1 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,25 @@
pipeline {
agent any
environment {
VOLUME_NAME = 'apps-data' // Nazwa woluminu Dockera
}
stages {
stage('Create Docker Volume') {
steps {
script {
// Sprawdzenie i tworzenie woluminu w jednym kroku
sh """
if ! docker volume ls --filter name=${VOLUME_NAME} --format '{{.Name}}' | grep -qw ${VOLUME_NAME}; then
docker volume create ${VOLUME_NAME}
echo "Volume '${VOLUME_NAME}' created successfully."
else
echo "Volume '${VOLUME_NAME}' already exists."
fi
"""
}
}
}
}
}