In my .gitlab-ci.yml file I want to send a notification to a WebexTeams or Spark room after each state. I can do this through a curl command (because webex teams or Spark use a REST API)
image:
name: hashicorp/terraform:light
entrypoint:
- '/usr/bin/env'
- 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
before_script:
- rm -rf .terraform
- terraform --version
- export AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY
- terraform init
.webexteams_variables: &webexteams_variables
roomId = "Y2l***NGQy"
.webexteams_send: &webexteams_send
script:
- curl --request POST --header 'Authorization: Bearer $bearer' --form 'roomId=$roomId' --form 'text=$msg' https://api.ciscospark.com/v1/messages
stages:
- validate
validate:
stage: validate
script:
- terraform validate
variables:
msg: "Validation complete"
<<: *webexteams_variables
<<: *webexteams_send
I'm getting an issue
Status: syntax is incorrect Error: jobs:validate:script config should be an array of strings or a string
Removing the quotes is fixing this issue but then I get the following
Running with gitlab-runner 12.0.1 (0e5417a3) on gitlab-runner iRWmYNFc Using Docker executor with image hashicorp/terraform:light ... Pulling docker image hashicorp/terraform:light ... Using docker image sha256:0cd71852a450fe70bb72b7f8084b11d7b8ecd34027e0cb1521680aa426415737 for hashicorp/terraform:light ... Running on runner-iRWmYNFc-project-11-concurrent-0 via wauterw-gitlab-runner... /bin/bash: line 69: export:
<<=roomId = "Y2l***Qy"': not a valid identifier /bin/bash: line 69: export:<<=roomId = "Y2l***Qy"': not a valid identifier ERROR: Job failed: exit code 1
Any idea how to fix this? If there are different ways to achieve this I would be interested to hear about them.