0
#!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.

1 Answer 1

0

According to the Groovy language docs, when defining a map literal, the keys should not be surrounded by double quotes. I.e.:

def payload = {
  data: {
    attributes: {
      some_key: "some_value"
    }
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.