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

Add condition to task queries

Abhishek kaushik February 10, 2023

Can you please help me with one of the queries.

I have a task running some powershell script. There is a variable being used inside the script and its value is coming out to be 0 or 1.

Basis on this variable output within the script, I need to do source checkout (another task) depending on "Add condition to task ".

I tried bamboo inject variable method but its not helping either as this will not work with injected variables, but only with plan or global ones

1 answer

1 accepted

2 votes
Answer accepted
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 13, 2023

Hello @Abhishek kaushik

Task conditioners work normally with Injected variables. Can you demonstrate how you are exporting, importing and consuming those variables?

Exported variables will derive from a Java properties format key=value. Eg.

  1. On a script task, create a variables.txt file with "go=yes"
  2. Add an Inject Bamboo Variables task and load that file. Se the namespace as "atlas" (example)
  3. On the task you wish to add the Conditional, select:
    1. Add a condition to task
    2. Variable atlas.go = yes
  4. If the injected variable "atlas.go" = yes then the Task on #3 will run.

 

Best regards,

Eduardo Alvarenga
Atlassian Support APAC

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

Abhishek kaushik February 13, 2023

Hi @Eduardo Alvarenga ,

I tried the similar steps but the source code checkout is not getting triggered as in the logs as it says "skipping task because of unfulfilled condition."

One thing i noticed is there are some weird special characters showing in the logs, is this expected or happening because of file formatting. I am doing echo "EXITCODE=$LASTEXITCODE" > EXITCODE.txt) in my powershell script

Injected variable bamboo.exitcodeinject.??E�X�I�T�C�O�D�E�=�0� in LOCAL scope
Injected variable bamboo.exitcodeinject.�= in LOCAL scope
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 13, 2023

Hello @Abhishek kaushik

This is a well-known issue with character encoding on Windows Please check this bug for a workaround:

I recommend you mark yourself as affected and also watch that bug to be notified when the final fix is implemented.

Best regards,

Eduardo Alvarenga
Atlassian Support APAC

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

Like Steffen Opel _Utoolity_ likes this
Abhishek kaushik February 13, 2023

Thanks @Eduardo Alvarenga 

I was able to do the source code checkout basis on above. However, UTF-8 was still showing weird special characters but when converted to ascii, it fixed everything. Here is my fix

echo EXITCODE=$LASTEXITCODE | Out-File -FilePath <File location with filename> -Encoding ascii

Like Eduardo Alvarenga likes this
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 13, 2023

Good job @Abhishek kaushik!

Make sure to Accept the solution provided if you were able to get the issue sorted.

Eduardo Alvarenga
Atlassian Support APAC

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events