Running this groovy jenkins script output this error "WorkflowScript: 17: expecting '}', found ':' @ line 17, column 11"
-
#!groovy env.BEARER_TOKEN = "uuuuuuuuuu" node { publishModule() } def publishModule() { stage('Deploy Modules') { } } def buildPayload() { def payload = { "data": { "attributes": { "vcs-repo": { "identifier":"nnnnnn", "oauth-token-id":"hhhhhh", "display_identifier":"nnnnnn" } "no-code": true }, "type":"registry-modules" } } } def deployModules() { def payload = buildPayload() def response = httpRequest( customHeaders: [ [ name: "Authorization", value: "Bearer " + env.BEARER_TOKEN], [ name: "Authorization", value: "application/vnd.api+json" ] ], httpMode: 'POST', responseBody: "${payload}", url: "https://app.terraform.io/api/v2/organizations/my-organization/registry-modules/vcs" ) }
WorkflowScript: 17: expecting '}', found ':' @ line 17, column 11. "data": { ^
I am trying to build this code in a Jenkinsfile so I am getting this error. WorkflowScript: 17: expecting '}', found ':' @ line 17, column 11. Any suggestion will be appreciated.
-
According to the https://groovy-lang.org/syntax.html#_maps , when defining a map literal, the keys should not be surrounded by double quotes. I.e.:
def payload = { data: { attributes: { some_key: "some_value" } } }