I want to setup a CD system for a yocto project which is version controlled in a bitbucket repository. I want to write a bitbucket pipeline which triggers a jenkins job on a build server which starts a yocto build. The reason for this is that yocto builds can take up anywhere to 6h for complete rebuilds and thats pretty costintensive with bitbucket pipelines. My idea to test this setup was to use docker containers so I can test the whole setup locally with ngrok. There are some questions I have regarding this:
- does the containerized setup for this make sense?
- can I mark a bitbucket pipeline build from the outside as in progress/completed/failed?
- what is the nicest way to trigger a jenkins job from bitbucket pipelines? Webhooks?
- how can I make jenkins differentiate between two branches when triggered by bitbucket pipelines?
The setup I am pondering with atm are two docker containers. One is running the jenkins server and the other is the build server with a custom image, which I have verified working. I found that you can instrument multiple containers using docker-compose so I came up with this docker-compose.yml:
version: '3'
services:
yocto-server:
build: .
container_name: yocto-server
networks:
- build-network
jenkins-master:
image: jenkins/jenkins
privileged: true
working_dir: /home/jenkins
depends_on:
- yocto-server
ports:
- 8080:8080
networks:
- build-network
links:
- yocto-server
networks:
build-network:
driver: bridge
Can jenkins invoke a command via ssh/telnet/docker magic to the second container with this setup? Because as I see it I have to do the following steps:
- mark the build in bbp as in progress
- if repository is present in the container pull and checkout a specific branch
- if repository is not pressent in the container clone it first run the build with parameters provided by jenkins
- depending on the exit code of the build flag the bbp build as completed/successfull
- upload the artifacts to bitbucket
I am very thankful for any inside on this because I have very little knowledge about docker-compose and jenkins.
For clarification I am using Bitbucket Cloud.