patternMinor
Bitbucket Pipeline & Jenkins & Yocto
Viewed 0 times
jenkinsbitbucketpipelineyocto
Problem
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:
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:
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:
run the build with parameter
- 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: bridgeCan 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 parameter
Solution
I think you're asking too many questions in one post for the StackExchange QA format, but I can address the Bitbucket-related questions.
- For automatically setting up jobs for each branch (and PR) in a Bitbucket project or repository, use the official Bitbucket Branch Source plugin. This will also take care of the build status aspect of your question.
- If you are using Bitbucket Cloud, the Bitbucket Branch Source plugin will also take care of creating webhooks in order to automatically trigger builds.
- If you are using Bitbucket Server, you will need some other way of triggering builds. I personally use the pull request notifier plugin for Bitbucket since our workflow is PR-based, but you can use whatever plugin or tool works for you - there are a ton of them out there.
Context
StackExchange DevOps Q#11700, answer score: 1
Revisions (0)
No revisions yet.