How to access Workflow Environment Variables

I have “targetBuild” Workflow Environment Variables
Next I have a simple script

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

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

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

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:                |
| toolkit: bash                                                                |
| time: 2020-06-29T08:46:51Z                                                   |
|                                                                              |
+ envman add --key targetBuild --value ''
+ echo Test
+ echo 'Test '
+ echo [REDACTED]
+ exit 1

cURL is something like

curl*/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.

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.