Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,640,587
Community Members
 
Community Events
196
Community Groups

Bamboo Yaml Spec Files checkout specific branch

I can't find a way in the yaml spec reference to checkout a specific branch of a (linked) repository. Creating an extra linked repository for each branch isn't a clean solution in my opinion.

Does anyone know about this?

2 answers

1 accepted

1 vote
Answer accepted
Richard White _TechTime_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
Jun 17, 2020

@danieldaeschle 

We ran into a similar problem, where we wanted to checkout specific tags or branches of dependencies, depending on the versions used in the main project that is being tested.

I did find a solution, but it is not exactly "clean" - in fact it is really complicated given the simplicity of what I wanted to achieve.

At the start of the build I defined a task, which parses the version of the dependency from the main build and exposes it as a "result variable". In our case they are all maven projects, so we use the Maven Pom Value Extractor plugin for this part.

Then I have defined stages to build each of dependencies. The first task in each of these stages uses a Script task to manually checkout the correct tag / branch of the dependency.

We use java specs so I don't have yaml version to hand, but the basic format is like this:

 

Stage 1 : Check dependency versions

  1. Extract dependency versions as result variables e.g `dependency_x_version` (Using pom value extractor)

Stage 2: Build dependency x

  1. Script task which checks out git branch or tag based on result variable `dependency_x_version`
  2. build dependency 1

...More stages for other dependencies

 

Final Stage:

- Build main product we want to test.

How do you manually checkout that branch?

Like 이준녕 likes this
Richard White _TechTime_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
Jun 17, 2020 • edited Jun 18, 2020

Oh, forgot to actually answer the question:

First we have a checkout task, which checks out the dependencies master branch.

Then, we have a script task with contents similar to below:

 

#!/bin/bash -x

EXPECTED="${bamboo_variable_for_target_branch}"

git branch -a
git checkout $EXPECTED

CURRENT=`git rev-parse --abbrev-ref HEAD`
if [ "$CURRENT" == "$EXPECTED"];
then
echo "Now on branch $CURRENT"
exit 0
fi

echo "On branch $CURRENT, either $EXPECTED does not exist or repo cache outdated

 

Notes:

- We had to select the option: "Fetch Whole Repository" on each linked repo

- We had to make sure to checkout each dependency into it's own working directory (and set the script task's working directory to match the dependency in question

Like danieldaeschle likes this
0 votes
Marcin Gardias
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Jun 17, 2020 • edited

Try sth. like this (requires Bamboo 6.10 or later)

version: 2

plan:
project-key: PRJ
key: PLAN
name: Plan name
master-branch: branchX

stages:
- Default stage:
- Default job

Default job:
tasks: []

triggers: []

 

i need it for another repository which will be checked out, not the main repository.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events