Créer le dépôt si il n’existe pas
Cadoles/Jenkins/pipeline/head There was a failure building this commit
Details
Cadoles/Jenkins/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
1efbd7f5ee
commit
5de4dfd4f8
|
@ -15,18 +15,37 @@ def exportPackages(
|
|||
return exportTasks
|
||||
}
|
||||
|
||||
def createRepository(
|
||||
String credentials,
|
||||
String name,
|
||||
String pulpHost = '192.168.30.3'
|
||||
) {
|
||||
def repositoryName = ["name": name]
|
||||
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 jsonResponse = readJSON text: response.content
|
||||
return waitForTaskCompletion(credentials, jsonResponse.task)
|
||||
|
||||
}
|
||||
def getRepositoryHREF(
|
||||
String credentials,
|
||||
String repositoryLevel = 'dev',
|
||||
String pulpHost = '192.168.30.3'
|
||||
) {
|
||||
def repositoriesMapping = ['dev': 'Cadoles4MSE']
|
||||
def repositoriesMapping = ['unstable': 'Cadoles4MSE unstable',
|
||||
'dev': 'Cadoles4MSE dev',
|
||||
'staging': 'Cadoles4MSE staging',
|
||||
'stable': 'Cadoles4MSE stable']
|
||||
def response = httpRequest authentication: credentials, url: "https://${pulpHost}/pulp/api/v3/repositories/deb/apt/", httpMode: 'GET', ignoreSslErrors: true
|
||||
def jsonResponse = readJSON text: response.content
|
||||
println(jsonResponse)
|
||||
def repositories = jsonResponse.results
|
||||
def repositoryHREF = repositories.find { it -> it['name'] == repositoriesMapping[repositoryLevel] }
|
||||
if (repositoryHREF) {
|
||||
return repositoryHREF.pulp_href
|
||||
} else {
|
||||
return createRepository(credentials, repositoriesMapping[repositoryLevel])[0]
|
||||
}
|
||||
}
|
||||
|
||||
def addToRepository(
|
||||
|
@ -37,7 +56,7 @@ def addToRepository(
|
|||
) {
|
||||
def packagesHREFURL = ["add_content_units": packagesHREF.collect { "https://$pulpHost$it" }]
|
||||
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:599"
|
||||
def response = httpRequest authentication: credentials, url: "https://${pulpHost}${repositoryHREF}modify/", httpMode: 'POST', requestBody: postBody, contentType: 'APPLICATION_JSON', ignoreSslErrors: true, validResponseCodes: "100:399"
|
||||
def jsonResponse = readJSON text: response.content
|
||||
return waitForTaskCompletion(credentials, jsonResponse.task)
|
||||
}
|
||||
|
@ -76,7 +95,7 @@ def distributePublication(
|
|||
url = '/pulp/api/v3/distributions/deb/apt/'
|
||||
}
|
||||
def postBody = JsonOutput.toJson(["publication": publicationHREF, "name": distributionName, "base_path": basePath, "content_guard": contentGuard])
|
||||
response = httpRequest authentication: credentials, url: "https://${pulpHost}${url}", httpMode: httpMode, requestBody: postBody, contentType: 'APPLICATION_JSON', ignoreSslErrors: true, validResponseCodes: "100:599"
|
||||
response = httpRequest authentication: credentials, url: "https://${pulpHost}${url}", httpMode: httpMode, requestBody: postBody, contentType: 'APPLICATION_JSON', ignoreSslErrors: true, validResponseCodes: "100:399"
|
||||
jsonResponse = readJSON text: response.content
|
||||
if (distribution) {
|
||||
waitForTaskCompletion(credentials, jsonResponse.task)
|
||||
|
|
Loading…
Reference in New Issue