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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Getting Bitbucket repo contents from triggers

Hello,

We are using Bamboo v6.3 and I wanted to get some help from experts regarding:

Q: Is there a way to checkout the only files from Bitbucket that were committed, pushed and caught by plan triggers?

What I am attempting to do is:

1- only checkout the files (from multiple subfolders) which triggered the plan's triggers (Repo polling, etc.) using "Source Code Checkout task" or something similar from plan

2- Generate Artifcats that only hold checked out files, etc. (e.g. in my case single file) and access it in the master build plan.

I am comfortable with the task-2 but not sure how to proceed or whether Bamboo can support something what is required at (1). I am assuming that since a change in repo (e.g. Bitbucket, etc.) can triggers a Bamboo plan, Bamboo must be knowing what has changed in that repo attached / linked to the plan Or is it too much to assume :(

 

Thanks,

1 answer

0 votes

Hello Irfan,

You cannot checkout only the modified files using the Source Code Checkout task, you will need a script task for this. The challenge is more related to git than Bamboo itself.

I was able to get it working with the following approach:

  1.  Create a plan with the repository you want to checkout and make sure the trigger is correctly configured
  2.  Remove the source code checkout task
  3.  Add a bash script task with the following content:
# Clean working directory
rm -rf *
# Clone your repository without a checkout
git clone --no-checkout http://admin:password@localhost:7990/bitbucket/scm/proj/repository.git
# Navigate to your repository folder
cd repository
# Get the the list of modified files
FILES=`git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT $bamboo_repository_revision_number`
# Checkout the modified files only
git checkout $bamboo_repository_revision_number -- $FILES 


References:

I hope it helps!

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bamboo

Bamboo 7.1 is here and is packed with value!

I'm happy to announce that Bamboo 7.1 has been released and it’s overflowing with awesome new features. Top-voted issues First and foremost, a bunch of JAC top voted issues has been delivered - y...

918 views 4 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you