Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Failed to parse PAYLOAD_FILE payload.json: invalid JSON provided

Hello guys 
Trying to integrate slack messages in my pipeline but receiving an "Invalid JSON provided" error. 

This is my pipeline: 

pipelines:
default:
- step:
name: Slack Notification
script:
- apt-get update && apt-get install gettext-base
- envsubst < ./pipeline/slack/payloads/payload_firebase_beta.json.template > ./pipeline/slack/payloads/payload_firebase_beta.json
- pipe: atlassian/slack-notify:2.0.0
variables:
WEBHOOK_URL: $WEBHOOK_URL
PRETEXT: 'New Android beta release was published to Firebase! 🚀🚀🚀'
PAYLOAD_FILE: ./pipeline/slack/payloads/payload_firebase_beta.json

payload_firebase_beta.json

{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "$WEBSITE"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Test mrkdwn text"
}
}
]
}

payload_firebase_beta.json.template 

WEBSITE="test website"

 Error:

INFO: Starting with payload provided in PAYLOAD_FILE...
INFO: Sending notification to Slack...
✖ Failed to parse PAYLOAD_FILE payload.json: invalid JSON provided.

Thank you in advance 

1 answer

1 vote
Mark C Atlassian Team Sep 20, 2021

Hi @Edgar Khimich

Thank you for reaching out to the community.

I've tested the same on my end.
However, using the JSON format you provided works fine on my end.
I tried providing an invalid JSON format to the Pipes script and I was able to reproduce the same error message.

For this, would it be possible for you to check the JSON format after the command envsubst?

- envsubst < ./pipeline/slack/payloads/payload_firebase_beta.json.template > ./pipeline/slack/payloads/payload_firebase_beta.json
- cat ./pipeline/slack/payloads/payload_firebase_beta.json

Let me know how it goes.

Regards,
Mark C

Sorry for a bit late response. 
It overwrites the payload_firebase_beta.json file with this text.

WEBSITE="test website"

It replaced the whole file instead of the specific veriable.
That's why it says that the JSON is invalid

Which envsubst command are you using that works from your side?
Should my file with variables (template) be in a template format or txt?
 

Okay
I found the reason why it didn't work.
I should have first export them as ENVIRONMENT VARS and only after that use it with envsubst.

- export RELEASE_DATE=$(date +'%b %d, %Y')
- envsubst < ./pipeline/slack/payloads/payload_firebase_beta.json.template > ./pipeline/slack/payloads/payload_firebase_beta.json

Now it works!

Like Oleksandr Kyrdan likes this
Mark C Atlassian Team Sep 27, 2021

Hi @Edgar Khimich

Glad to know you've found the reason why it didn't work.

Thank you also for sharing your solution.

Let me know if you have further questions.

Regards,
Mark C

Like Oleksandr Kyrdan likes this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across their  Jira Cloud instance.  ...

551 views 15 18
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you