3

Trying to set body parameter for post method in jenkins, build fails because of error unexpected "(" script returned with error status 2.

Following is the attached code stage in jenkins:

script{
    sh ("pip install semgrep")
    semgrep_result = sh(script:"semgrep --config=p/r2c-ci src --json", 
                        returnStdout:true).trim()

    echo "semgrep_res $semgrep_result"

    sh"""
      curl -X POST \
           -d "result":"$semgrep_result" \
           -d "discovery_source":"SAST" \
           -d "reponame":"v*****" \
           'https://dev************/get_scan_data'
      """
}

It gives error as [2021-09-08T02Z] /home//ace/pi-changes-for-tools-
integration@tmp/durabl
*/script.sh: 1: /home/j
*/***pi-changes-for-tools-
integration@tmp/durable-/script.sh: Syntax error: "(" unexpected script returned exit code

Tried trim along with sh script still gives same error

Can anybody tell what is wrong?

John Vandenberg
  • 474
  • 6
  • 16
  • Looks like your bash script is not syntactically valid. Are you missing a \ at the end of line 3? what happens if you make the right hand side of `semgrep_result` all on the same line? – ine Nov 06 '21 at 14:32

0 Answers0