Currently it creates a network name "denpal_default" and it does give this message:
[1BRemoving network denpal_default
Network denpal_default not found.
Network test-network is external, skipping
I haven't tested it yet, but I assume if it makes the denpal_default network and deletes it, it cannot run multiple builds at the same time.
I was thinking about a solution that would create a random COMPOSE_PROJECT_NAME="denpal-randomnumber" and build based on that.
But how do I use a variable set in the "Docker build"-stage in the "Verification"-stage later on?
stage('Docker Build') {
steps {
sh '''
docker-compose config -q
docker network prune -f && docker network inspect test-network >/dev/null || docker network create test-network
COMPOSE_PROJECT_NAME=denpal docker-compose down
COMPOSE_PROJECT_NAME=denpal docker-compose up -d --build "$@"
'''
}
}
stage('Verification') {
steps {
sh '''
docker-compose exec -T cli curl http://nginx:8080 -v
COMPOSE_PROJECT_NAME=denpal docker-compose down
'''
}
}