refactor: refs #6695 simplify Docker cleanup commands in Jenkinsfile
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
c9ffaae3b3
commit
79e2a7ee25
|
@ -178,30 +178,9 @@ def cleanDockerE2E() {
|
|||
script {
|
||||
def projectBranch = "${PROJECT_NAME}-${env.BRANCH_NAME}".toLowerCase()
|
||||
// STOP AND REMOVE
|
||||
def containers = sh(script: """
|
||||
docker ps --filter "name=^${projectBranch}" --format "{{.ID}}"
|
||||
""", returnStdout: true).trim()
|
||||
sh """docker ps -a --filter "name=^${projectBranch}" | awk 'NR>1 {print $1}' | xargs -r docker rm -v || true"""
|
||||
sh """docker network ls --filter "name=^${projectBranch}" | awk 'NR>1 {print $1}' | xargs -r docker network rm || true"""
|
||||
|
||||
if (containers) {
|
||||
sh(script: """
|
||||
echo '${containers}' | xargs docker stop
|
||||
echo '${containers}' | xargs docker rm
|
||||
""")
|
||||
} else {
|
||||
echo "No se encontraron contenedores con el prefijo '${projectBranch}'."
|
||||
}
|
||||
|
||||
def networks = sh(script: """
|
||||
docker network ls --filter "name=^${projectBranch}" --format "{{.ID}}"
|
||||
""", returnStdout: true).trim()
|
||||
|
||||
if (networks) {
|
||||
sh(script: """
|
||||
echo '${networks}' | xargs docker network rm
|
||||
""")
|
||||
} else {
|
||||
echo "No se encontraron redes con el prefijo '${projectBranch}'."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue