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.
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--
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.