slack-notify v1.0.0 now fails on message that previously succeeded

Shaun Dishman March 25, 2021

We have been using slack-notify to post messages about deployment status.  I recently attempted to upgrade from 0.3.6 to 1.0.0, and now an error occurs.

Here is an example message that was working pre-upgrade:

[fake/stage]: Deployed stage-v1.1.0-SC21.03.2-clarus-21.03.2 (Shaun Dishman)

Do I need to escape the square brackets or something?  Or perhaps the forward-slash?

 

I am attaching a screenshot of the pipeline error.

For now I'm going to downgrade the pipe version, but it's a bit disappointing/frustrating to fail in an unexpected way.

Thanks in advance for assistance.

 

bitbucket-pipelines-slack-error.png

1 answer

0 votes
Halyna Berezovska
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 26, 2021

@Shaun Dishmanthanks for raising this question!

Could you please, share the pipeline of how you're using the pipe?

It is important for us to see how you pass variables to the pipe. I see root cause can be there.

Regards, Galyna

Shaun Dishman March 26, 2021

I figured you might ask for that.  We use it in an `after-script` block.  I'll just include that block for brevity.  If you need the whole pipeline I can provide it, although I think it would just add a lot more noise:

 

after-script: &notify-slack
- apk add -q --no-progress curl jq
- export BITBUCKET_TRIGGERER_USERNAME=$(curl -X GET -g "https://api.bitbucket.org/2.0/users/${BITBUCKET_STEP_TRIGGERER_UUID}" | jq --raw-output '.display_name')
- export BUILD_TAG=$(/root/deploy/deploy_tools/simple/build_tag "$BITBUCKET_CLONE_DIR" "$BITBUCKET_DEPLOYMENT_ENVIRONMENT")
- if [[ $BITBUCKET_EXIT_CODE -eq 0 ]]; then export MESSAGE="Deployed ${BUILD_TAG}"; else export MESSAGE="Failed deployment of ${BUILD_TAG}"; fi

- pipe: atlassian/slack-notify:0.3.6
variables:
WEBHOOK_URL: $SLACK_WEBHOOK_URL
MESSAGE: '[${CLIENT_NAME}/${BITBUCKET_DEPLOYMENT_ENVIRONMENT}]: ${MESSAGE} (${BITBUCKET_TRIGGERER_USERNAME})'
# DEBUG: "true"
Halyna Berezovska
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 29, 2021

@Shaun Dishmanyes, that is enough, thanks! I guess I can see the root cause - you're using `[` `]` characters, that are considered as structure.

Looks like this is a bug, starting from 1.0.0 version.

Temporary workaround for you,  if you need the pipeline to succeed just right now : you can downgrade to previous versions. Unfortunately, I don't see other options for this case.

I'll notify once we release bugfix for your case.

Regards, Galyna

Shaun Dishman March 29, 2021

Thanks for the investigation.  As I mentioned in my initial summary, I've already downgraded back to 0.3.6 and it works fine.  But it would be nice to stay abreast of the latest updates, so I'll be interested to hear when a fix comes out.

Like Halyna Berezovska likes this
Halyna Berezovska
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 23, 2021

@Shaun Dishman could you try use the same version but adding extra quotes? So your variable could look like this:

MESSAGE: '"[${CLIENT_NAME}/${BITBUCKET_DEPLOYMENT_ENVIRONMENT}]: ${MESSAGE} (${BITBUCKET_TRIGGERER_USERNAME})"'

Thanks! Sorry for late response .

It is the question how pipeline infra is parsing things. In bash scripts they are understood differently, than in python.

Shaun Dishman April 23, 2021

That appears to work.  I expected it to show a set of double-quotes in the resultant slack message, but it doesn't.

Halyna Berezovska
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 25, 2021

 @Shaun Dishman yes, because this is the way how pipeline parses the variables. We will update documentation

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events