Jenkins Pipeline Custom Scripts (shutdown application) -
i have several jenkins pipelines in case call "docker-compose up" @ end of build run containers/application. now, don't need containers/application time , have way jenkins pipeline page shutdown (docker-compose stop) application free resources other builds. know way this?
you can declare choice parameter (ex: stop_containers) values yes , no in jenkins job responsible stopping containers.
then in build section select execute shell , add following script it:
#!/bin/bash if [ "$stop_containers" = "yes" ] //command stopping containers.... else echo "do nothing." fi now, whenever run job ask if want stop containers or not. choose required option, yes if want stop containers.
if pipeline job can define stage perform stopping container operation.
stage('stop containers') { properties( [parameters([choice(choices: ["yes", "no"].join("\n"), description: 'some choice parameter', name: 'stop_containers')])]) agent label:'some-node' when { expression { return env.stop_containers = 'yes'; } } steps { //command stop containers } }
Comments
Post a Comment