Hello,
I have generic step to send slack message. It is using BB in-house pipe.
However, I want to reuse this step in later steps with overriding env varibales.
How I can do that ?
( we deliberately want to use variables to be present in bitbucket pipeline file and not relay on UI option bitbucket provide, since it is hard to have "change control" over there )
- step: ¬ify_step
script: &slack_pipe
- pipe: atlassian/slack-notify:2.0.0
variables:
WEBHOOK_URL: $WEBHOOK_URL
PRETEXT: "*Hello*"
MESSAGE: "MYVAR is $MYVAR"
- step: ¬ify_staging
<<: *notify_step
name: Notify Staging
script:
- export MYVAR=xxx
- *slack_pipe
Code above doesn't work:
This section should be a string or a map (it is currently defined as a list).
Hi @Պարապ Սարապ and welcome to the community!
If you use overrides with <<: *notify_step, you cannot add a script with additional commands in the step.
What you can do instead is add a definition for the pipe and then use this definition in different steps. An example is the following:
image: atlassian/default-image:4
definitions:
pipes:
- pipe: &slack_pipe
pipe: atlassian/slack-notify:2.0.0
variables:
WEBHOOK_URL: $WEBHOOK_URL
PRETEXT: "*Hello*"
MESSAGE: "MYVAR is $MYVAR"
pipelines:
default:
- step:
name: Notify staging
script:
- export MYVAR="XXX"
- *slack_pipe
- step:
name: Notify production
script:
- export MYVAR="YYY"
- *slack_pipe
Does this work for you?
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.