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

Extracting value from bamboo variables

Edited

There is a bamboo variable bamboo.planRepository.branchName that I am trying to use and extract some partial value and not as whole value.

 

I am using this variable as deployment release generation so i was trying this

${bamboo.planRepository.branchName}.Remove(1,5)-${bamboo.inject.shortCommitHash}-${bamboo.buildNumber}

but Remove does not work , basically I am trying to find if I do string manipulation.

or is there any way we can have custom variable which is basically string manipulation of this bamboo variables.

1 answer

1 accepted

1 vote
Answer accepted
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Dec 25, 2022

Hello @Syed Imtiyaz Alam

Bamboo will add several environment variables that can be used on your Tasks. To have those variables changed and reinjected, you will have to use a Script Task and do the conversion there using either a Linux shell or Windows Powershell, or any other strung manipulation techniques you prefer.

After you have created the new variables, add them to a text file using a Java properties format (key=value) and later on add an Inject Bamboo variables task to pass the new variable to the next Tasks of the same Job or possibly other Stages (if using a "Result" scope). I assume you already use something like that due to the "${bamboo.inject...}" example you've added to the question.

For example, you can run the following bash shell script to create a new string and feed it to a text file for later import:

#!/bin/bash
# Assuming bamboo_planRepository_branchName="Bamboo555" and I want it to extract only the "555" from it
# bamboo_planRepository_branchName="Bamboo555"
stripped_branch="${bamboo_planRepository_branchName:6}"

release_name="${stripped_branch}-${bamboo_inject_shortCommitHash}-${bamboo_buildNumber}"

echo "release_name=${release_name}" > release_name.txt
$ cat release_name.txt
release_name=555-abfg38bc-103

Then import "release_name.txt" in an Inject Bamboo variables task and use it as "${bamboo.inject.release_name}" or "${bamboo_inject_release_name}" if used by a shell script.

Sincerely,

Eduardo Alvarenga
Atlassian Support APAC

--please don't forget to Accept the answer if the reply is helpful-- 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events