Hi,
I have written a custom pipe that accepts variables. If I explicitly pass the variables to the pipe in my bitbucket-pipelines.yml file, it works as expected. However, from some of the documentation I have read online (specifically this one - see Default Variables section), it suggests that it should be able to read the variables from the context.
There is a good chance that I have misunderstood what this means. I am assuming that any environment variable that I have defined at the account, repository or deployment level would get passed into the pipe when I define a variable in the pipe.yml and default it to the environment variable - as shown on that linked article. However, if I do not explicitly pass the variable into the pipe then it doesn't work.
Is there a step I have missed, or something I have not enabled etc to get this to work? Or I have misunderstood the feature and it is not possible. Any help would be greatly appreciated.
Here is what I have put together.
I have created the repository variable.


Custom Pipe:
Dockerfile
FROM alpine:3.11
RUN apk --update --no-cache add \
bash
RUN wget -P / https://bitbucket.org/bitbucketpipelines/bitbucket-pipes-toolkit-bash/raw/0.4.0/common.sh
COPY ./pipe.sh ./pipe.yml /
ENTRYPOINT ["/pipe.sh"]
pipe.sh
#!/usr/bin/env bash
#
# Echos the test variable
#
# Required globals:
# TEST_VARIABLE
#
source "$(dirname "$0")/common.sh"
# mandatory parameters
TEST_VARIABLE=${TEST_VARIABLE:?'TEST_VARIABLE variable is missing.'}
echo ${TEST_VARIABLE}
success 'Test variable has been passed through'
pipe.yml
name: CustomPipe
variables:
- name: TEST_VARIABLE
default: '${TEST_VARIABLE}'
Pipeline:
bitbucket-pipelines.yml - This version works
image:
name: atlassian/default-image:2
pipelines:
branches:
master:
- step:
name: Run pipe
script:
- pipe: <url for pipe>
variables:
TEST_VARIABLE: ${TEST_VARIABLE}
This succeeds echoing the value in the variable and displays the success message:
<span>Testing</span><span>✔ </span>
<span>Test variable has been passed through</span>
bitbucket-pipelines.yml - My assumption is that this version should work too, but it fails
image:
name: atlassian/default-image:2
pipelines:
branches:
master:
- step:
name: Run pipe
script:
- pipe: <url for pipe>
I get this failure message as per the pipe.sh:
/pipe.sh: line 12: TEST_VARIABLE: TEST_VARIABLE variable is missing.