Restreindre les codes retours valides
Cadoles/Jenkins/pipeline/head This commit looks good
Details
Cadoles/Jenkins/pipeline/head This commit looks good
Details
This commit is contained in:
parent
44764866a8
commit
97abfb0ade
|
@ -6,7 +6,7 @@ def getResourceHREF(
|
||||||
String resourceName,
|
String resourceName,
|
||||||
String pulpHost = '192.168.30.3'
|
String pulpHost = '192.168.30.3'
|
||||||
) {
|
) {
|
||||||
def response = httpRequest authentication: credentials, url: "https://${pulpHost}/pulp/api/v3/${resourceEndpoint}", httpMode: 'GET', ignoreSslErrors: true
|
def response = httpRequest authentication: credentials, url: "https://${pulpHost}/pulp/api/v3/${resourceEndpoint}", httpMode: 'GET', ignoreSslErrors: true, validResponseCodes: "200"
|
||||||
def jsonResponse = readJSON text: response.content
|
def jsonResponse = readJSON text: response.content
|
||||||
def resource = jsonResponse.results.find { it -> it.name == resourceName}
|
def resource = jsonResponse.results.find { it -> it.name == resourceName}
|
||||||
if (resource) {
|
if (resource) {
|
||||||
|
@ -22,17 +22,18 @@ def waitForTaskCompletion(
|
||||||
) {
|
) {
|
||||||
def status = ''
|
def status = ''
|
||||||
def created_resources = []
|
def created_resources = []
|
||||||
while (status == 'running') {
|
while (status != 'completed') {
|
||||||
def response = httpRequest authentication: credentials, url: "https://${pulpHost}${taskHREF}", httpMode: 'GET', ignoreSslErrors: true
|
def response = httpRequest authentication: credentials, url: "https://${pulpHost}${taskHREF}", httpMode: 'GET', ignoreSslErrors: true, validResponseCodes: "200"
|
||||||
def jsonResponse = readJSON text: response.content
|
def jsonResponse = readJSON text: response.content
|
||||||
status = jsonResponse.state
|
status = jsonResponse.state
|
||||||
if (status == 'completed') {
|
if (status == 'completed') {
|
||||||
return jsonResponse.created_resources
|
return jsonResponse.created_resources
|
||||||
} else if (status == 'failed') {
|
} else if (!(status in ['running','waiting'])) {
|
||||||
throw new Exception("Task failed:" + jsonResponse.error.description)
|
break
|
||||||
}
|
}
|
||||||
sleep(10)
|
sleep(10)
|
||||||
}
|
}
|
||||||
|
throw new Exception("Task failed:" + jsonResponse.error.description)
|
||||||
}
|
}
|
||||||
|
|
||||||
def exportPackages(
|
def exportPackages(
|
||||||
|
@ -42,7 +43,7 @@ def exportPackages(
|
||||||
) {
|
) {
|
||||||
def exportTasks = []
|
def exportTasks = []
|
||||||
packages.each {
|
packages.each {
|
||||||
def response = httpRequest authentication: credentials, url: "https://${pulpHost}/pulp/api/v3/content/deb/packages/", httpMode: 'POST', ignoreSslErrors: true, multipartName: "file", timeout: 900, uploadFile: "${it}"
|
def response = httpRequest authentication: credentials, url: "https://${pulpHost}/pulp/api/v3/content/deb/packages/", httpMode: 'POST', ignoreSslErrors: true, multipartName: "file", timeout: 900, uploadFile: "${it}", validResponseCodes: "202"
|
||||||
def jsonResponse = readJSON text: response.content
|
def jsonResponse = readJSON text: response.content
|
||||||
exportTasks << jsonResponse['task']
|
exportTasks << jsonResponse['task']
|
||||||
}
|
}
|
||||||
|
@ -56,7 +57,7 @@ def createRepository(
|
||||||
) {
|
) {
|
||||||
def repositoryName = ["name": name]
|
def repositoryName = ["name": name]
|
||||||
def postBody = JsonOutput.toJson(repositoryName)
|
def postBody = JsonOutput.toJson(repositoryName)
|
||||||
def response = httpRequest authentication: credentials, url: "https://${pulpHost}/pulp/api/v3/repositories/deb/apt/", httpMode: 'POST', requestBody: postBody, contentType: 'APPLICATION_JSON', ignoreSslErrors: true, validResponseCodes: "100:399"
|
def response = httpRequest authentication: credentials, url: "https://${pulpHost}/pulp/api/v3/repositories/deb/apt/", httpMode: 'POST', requestBody: postBody, contentType: 'APPLICATION_JSON', ignoreSslErrors: true, validResponseCodes: "202"
|
||||||
def jsonResponse = readJSON text: response.content
|
def jsonResponse = readJSON text: response.content
|
||||||
return jsonResponse.pulp_href
|
return jsonResponse.pulp_href
|
||||||
|
|
||||||
|
@ -81,7 +82,7 @@ def addToRepository(
|
||||||
) {
|
) {
|
||||||
def packagesHREFURL = ["add_content_units": packagesHREF.collect { "https://$pulpHost$it" }]
|
def packagesHREFURL = ["add_content_units": packagesHREF.collect { "https://$pulpHost$it" }]
|
||||||
def postBody = JsonOutput.toJson(packagesHREFURL)
|
def postBody = JsonOutput.toJson(packagesHREFURL)
|
||||||
def response = httpRequest authentication: credentials, url: "https://${pulpHost}${repositoryHREF}modify/", httpMode: 'POST', requestBody: postBody, contentType: 'APPLICATION_JSON', ignoreSslErrors: true, validResponseCodes: "100:399"
|
def response = httpRequest authentication: credentials, url: "https://${pulpHost}${repositoryHREF}modify/", httpMode: 'POST', requestBody: postBody, contentType: 'APPLICATION_JSON', ignoreSslErrors: true, validResponseCodes: "202"
|
||||||
def jsonResponse = readJSON text: response.content
|
def jsonResponse = readJSON text: response.content
|
||||||
return waitForTaskCompletion(credentials, jsonResponse.task)
|
return waitForTaskCompletion(credentials, jsonResponse.task)
|
||||||
}
|
}
|
||||||
|
@ -100,7 +101,7 @@ def publishRepository(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
def postBody = JsonOutput.toJson(postContent)
|
def postBody = JsonOutput.toJson(postContent)
|
||||||
def response = httpRequest authentication: credentials, url: "https://${pulpHost}/pulp/api/v3/publications/deb/apt/", httpMode: 'POST', requestBody: postBody, contentType: 'APPLICATION_JSON', ignoreSslErrors: true
|
def response = httpRequest authentication: credentials, url: "https://${pulpHost}/pulp/api/v3/publications/deb/apt/", httpMode: 'POST', requestBody: postBody, contentType: 'APPLICATION_JSON', ignoreSslErrors: true, validResponseCodes: "202"
|
||||||
def jsonResponse = readJSON text: response.content
|
def jsonResponse = readJSON text: response.content
|
||||||
return waitForTaskCompletion(credentials, jsonResponse.task)
|
return waitForTaskCompletion(credentials, jsonResponse.task)
|
||||||
}
|
}
|
||||||
|
@ -131,7 +132,7 @@ def distributePublication(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
def postBody = JsonOutput.toJson(bodyContent)
|
def postBody = JsonOutput.toJson(bodyContent)
|
||||||
response = httpRequest authentication: credentials, url: "https://${pulpHost}${url}", httpMode: httpMode, requestBody: postBody, contentType: 'APPLICATION_JSON', ignoreSslErrors: true, validResponseCodes: "100:399"
|
response = httpRequest authentication: credentials, url: "https://${pulpHost}${url}", httpMode: httpMode, requestBody: postBody, contentType: 'APPLICATION_JSON', ignoreSslErrors: true, validResponseCodes: "202"
|
||||||
jsonResponse = readJSON text: response.content
|
jsonResponse = readJSON text: response.content
|
||||||
if (distributionHREF) {
|
if (distributionHREF) {
|
||||||
waitForTaskCompletion(credentials, jsonResponse.task)
|
waitForTaskCompletion(credentials, jsonResponse.task)
|
||||||
|
@ -146,7 +147,7 @@ def getDistributionURL(
|
||||||
String resourceHREF,
|
String resourceHREF,
|
||||||
String pulpHost = '192.168.30.3'
|
String pulpHost = '192.168.30.3'
|
||||||
) {
|
) {
|
||||||
def response = httpRequest authentication: credentials, url: "https://${pulpHost}${resourceHREF}", httpMode: 'GET', ignoreSslErrors: true
|
def response = httpRequest authentication: credentials, url: "https://${pulpHost}${resourceHREF}", httpMode: 'GET', ignoreSslErrors: true, validResponseCodes: "200"
|
||||||
def jsonResponse = readJSON text: response.content
|
def jsonResponse = readJSON text: response.content
|
||||||
println(jsonResponse)
|
println(jsonResponse)
|
||||||
return jsonResponse.base_url
|
return jsonResponse.base_url
|
||||||
|
|
Loading…
Reference in New Issue