0

I need some help I'm really struggling through a way to pass a variable to a JSON using curl.

I have a very limited docker to use inside circle ci, and I'm trying to send to slack webhook some info that I saved on the variable.

I tried: "'"$var"'" /"$var/" and some many other ways, I'm out of clue.

Please someone can help me with that?

I posted the content of the first command below the bash script.

Thanks in advance for any tips or help!

Here's my code:

#!/bin/bash -x
cypress=$(npx cypress run --spec "cypress/integration/staging_UX/02_login_error.js" | tail -n -7)
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"Staging Tests Results: \n $cypress\"}" https://hooks.slack.com/services/...

Content of $cypress

 Spec                                              Tests  Passing  Failing  Pending  Skipped  
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ ✔  staging_UX/02_login_error.js             00:07        1        1        -        -        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ✔  All specs passed!                        00:07        1        1        -        -        -  
    

  • check this https://stackoverflow.com/questions/17029902/using-curl-post-with-variables-defined-in-bash-script-functions – Bala Jul 18 '21 at 16:16

0 Answers0