title: How to pass json body to curl command from jenkins pipeline in groovy
body: <p>It seems like impossible to pass a string that represents json body for POST request with curl using <em>sh</em> command inside Jenkins Pipeline.</p>
  
  <p>I have the following <em>sh</em> line inside a pipeline step:</p>
  
  <pre><code>def apiCmd = 'curl -X POST --user user:passe --data  \\"{\\"state\\":\\"' + stateStr + '\\",\\"context\\":\\"branch-regression\\"}\\"' + " --url ${Configuration.CommitStatusUpdateURL}
  </code></pre>
  
  <p>now what Jenkins actually runs is:</p>
  
  <pre><code>curl -X POST --user user:pass--data '""state":"failure""' '""context":"branch-regression""' --url someurl
  </code></pre>
  
  <p>What is so annoying is that if you want to run the post request with native groovy Jenkins complaints about security stuff.. and if you try with Curl then the JSON isn't parsed well </p>