0

When I do docker run I have to give extensive argument options for my container setup. To mitigate this and ensure all developers are using the same arguments I switched to docker-compose.

Now when I try to go run the same build from jenkins I can no longer use the docker plugin since no jenkins plugins seem to support docker-compose up, they all need to use the docker commands for the remote API instead of the docker-compose commands.

Unless there are reasons not to, I would prefer docker-compose up. I am aware I could create a bash script the does docker run <arguments> and let my jenkinsfile parse the script and load in the proper args but this feels ultra hacky.

How can I use one or the other and keep them both in SCM and ensure that if a change is made to docker source (either the docker-compose.yml or possible a bash script running docker run with the proper arguments), it will work in both places? Are there tools for this? a plugin I am missing?

Also I desire to use CoreOs which doesn't natively support jenkins (no java and other things).

0

If you have docker compose installed on the Jenkins Build machine you can use sh docker-compose up to run docker-compose from a new shell.

In general, you can run any command from your JenkinsFile using the sh command.

  • See here for possible hangups and workarounds. reinout.vanrees.org/weblog/2017/10/03/… – avi Feb 27 '18 at 5:45
  • I am running on coreos, which doesn't support working as a jenkins slave (to my knowledge), without doing a bunch of manual steps. I thought that was the purpose of using the docker api so you didn't need to connect to a jenkins slave in the traditional way and could just rely on the remote api? – scott Feb 27 '18 at 18:16
  • @scott I think you still need the slave so it can report the status etc. The benefit of docker is your environment is clean and the same from the build to the deployment. – avi Feb 28 '18 at 12:20

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.