从Jenkins声明式管道运行curl命令

时间:2020-09-18 02:36:04

标签: jenkins curl jira jenkins-declarative-pipeline

我正在尝试从Jenkins声明性管道执行curl post命令,但是,它引发了语法错误-期望'}'找到了':'

管道脚本如下:

管道{

代理{标签'Linux01'}

阶段{

  stage('Hello') {

     steps {

        sh 'curl -u username:password -X POST -d '{"body":"Jenkinspipleinecomment"}' -H "Content-Type:application/json" http://localhost:8080/rest/api/2/issue/someissue/comment'

     }
  }

} }

请帮助。

1 个答案:

答案 0 :(得分:0)

尝试一下

pipeline {

agent { label ' Linux01'}

stages {

  stage('Hello') {

     steps {

        sh """curl -u username:password -X POST -d '{"body":"Jenkinspipleinecomment"}' -H "Content-Type:application/json" http://localhost:8080/rest/api/2/issue/someissue/comment"""

     }
  }
} }