def publishVersion() {
def Payload = versionPayload()
def response = httpRequest(
customHeaders: [
[ name: "Authorization", value: "Bearer " + env.BEARER_TOKEN ],
[ name: "Content-Type", value: "application/vnd.api+json" ]
],
httpMode: 'POST',
requestBody: "${Payload}",
url: "https://app.terraform.io/api/v2/organizations/my-organization/registry-modules/private/my-organization/vnet/provider/versions"
)
def data = new JsonSlurper().parseText(response.content)
println ("Run Id: " + data.data.links.upload)
return data.data.links.upload
}
def UPLOAD
UPLOAD = sh(
'''curl \
--header "Content-Type: application/octet-stream" \
--request PUT \
--data-binary @module.tar.gz \
data.data.links.upload
'''
)
I am trying to create a module version in Terraform cloud. The publishVersion() method will invoke the API call and part of the API response is a URL where the module will be uploaded. And that URL is what publishVersion() is returning as data.data.links.upload. The URL returned by the publishVersion() method, I am trying to upload the module.tar.gz to the URL by using the UPLOAD method in the last part. "it says could not resolve host."
Probably you have to do something like the below.