How to access Workflow Environment Variables

Hello!
I have “targetBuild” Workflow Environment Variables
%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5
Next I have a simple script

#!/usr/bin/env bash
set -ex

envman add --key targetBuild --value "${targetBuild}"

echo "Test" $targetBuild
echo "Test $targetBuild"
echo $GIT_REPOSITORY_URL

exit 1

But when I run build from curl I can’t access my variable

INFO[08:46:44] Step uses latest version -- Updating StepLib ... 
+------------------------------------------------------------------------------+
| (0) Замена адреса сервера                                 |
+------------------------------------------------------------------------------+
| id: script                                                                   |
| version: 1.1.6                                                               |
| collection: https://github.com/bitrise-io/bitrise-steplib.git                |
| toolkit: bash                                                                |
| time: 2020-06-29T08:46:51Z                                                   |
+------------------------------------------------------------------------------+
|                                                                              |
+ envman add --key targetBuild --value ''
+ echo Test
Test
+ echo 'Test '
Test 
+ echo [REDACTED]
[REDACTED]
+ exit 1

cURL is something like

curl https://app.bitrise.io/app/*/build/start.json --data '{"hook_info": "type":"bitrise","build_trigger_token":"*"},"build_params":{"branch":"master","environments": {"mapped_to":"targetBuild","value":"release","is_expand":true}]},"triggered_by":"curl"}'

It seems that you are overwriting value passed by trigger by a workflow environment variable.

If you want to always pass it via trigger then remove workflow environment variable.

BTW
Such statement:
envman add --key targetBuild --value "${targetBuild}"
is effectively a no-op. You are writing the same value which is already present.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.