We have developed a nice custom template for our Slack posts. Ideally, we could use this template across all of our projects without duplicating it. However, when we attempt to read the string from a Context Environment variable, it fails the JQ parsing. Most of the errors are very similar to:
parse error: Invalid numeric literal at line 1, column 16
The actual JSON is pretty straight forward
{
"attachments": [{
"color": "#5CBB8B",
"pretext": "Build #$CIRCLE_BUILD_NUM of *$CIRCLE_PROJECT_REPONAME* project has passed",
"title": "$CIRCLE_STAGE Results",
"title_link": "$CIRCLE_BUILD_URL",
"text": "<< pipeline.parameters.commitMessage >>",
"footer": "<< pipeline.parameters.authorName >> | $CIRCLE_BRANCH | ${CIRCLE_SHA1:1:6}",
"footer_icon": "https://github.com/<< pipeline.parameters.authorUserName >>.png?size=32"
}]
}
We have tried placing the text within the JQ playground at jqplay.org and it parses correctly. We have also tried a TON of ways to evaluate the ENV within our YML file as we have seen ENVs be evaluated differently based on the Orb / command they are being evaluated within. Nothing works.
We do have a working solution using Pipeline parameters, but that still requires the duplication across projects.
Any suggestions for storing our Slack message template JSON in a reusable way?