Issue
I am trying to execute the curl post command from Jenkins declarative pipeline, however, it is throwing a syntax error -- Expecting '}' found ':'
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'
}
}
}
}
Kindly help.
Solution
Try this out
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"""
}
}
} }
Answered By - Sourav Answer Checked By - Candace Johnson (WPSolving Volunteer)