retour en arrière
Cadoles/Jenkins/pipeline/head This commit looks good Details

This commit is contained in:
vfebvre 2022-06-07 11:22:21 +02:00
parent a31b64b5b6
commit 63af3c7121
1 changed files with 148 additions and 161 deletions

View File

@ -1,23 +1,12 @@
import groovy.json.JsonOutput
def call() {
pipeline {
parameters {
string(
name: 'pulpHost',
description: 'Nom de domaine pour le serveur Pulp',
defaultValue: ''
)
}
def getResourceHREF(
String credentials,
String resourceEndpoint,
String resourceName,
// String pulpHost
String pulpHost = 'pulp.cadoles.com'
) {
def response = httpRequest authentication: credentials, url: "https://${params.pulpHost}/pulp/api/v3/${resourceEndpoint}", httpMode: 'GET', ignoreSslErrors: true, validResponseCodes: "200"
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 resource = jsonResponse.results.find { it -> it.name == resourceName}
if (resource) {
@ -29,7 +18,7 @@ def call() {
def waitForTaskCompletion(
String credentials,
String taskHREF,
String pulpHost
String pulpHost = 'pulp.cadoles.com'
) {
def status = ''
def created_resources = []
@ -50,7 +39,7 @@ def call() {
def exportPackages(
String credentials,
List packages = [],
String pulpHost
String pulpHost = 'pulp.cadoles.com'
) {
def exportTasks = []
packages.each {
@ -64,7 +53,7 @@ def call() {
def createRepository(
String credentials,
String name,
String pulpHost
String pulpHost = 'pulp.cadoles.com'
) {
def repositoryName = ["name": name]
def postBody = JsonOutput.toJson(repositoryName)
@ -89,7 +78,7 @@ def call() {
String credentials,
List packagesHREF,
String repositoryHREF,
String pulpHost
String pulpHost = 'pulp.cadoles.com'
) {
def packagesHREFURL = ["add_content_units": packagesHREF.collect { "https://$pulpHost$it" }]
def postBody = JsonOutput.toJson(packagesHREFURL)
@ -102,7 +91,7 @@ def call() {
String credentials,
String repositoryHREF,
String signing_service = null,
String pulpHost
String pulpHost = 'pulp.cadoles.com'
) {
def postContent = ["repository": repositoryHREF, "simple": true]
if (signing_service) {
@ -123,7 +112,7 @@ def call() {
String distributionName,
String basePath,
String contentGuard = null,
String pulpHost
String pulpHost = 'pulp.cadoles.com'
) {
def httpMode = ''
def url = ''
@ -156,12 +145,10 @@ def call() {
def getDistributionURL(
String credentials,
String resourceHREF,
String pulpHost
String pulpHost = 'pulp.cadoles.com'
) {
def response = httpRequest authentication: credentials, url: "https://${pulpHost}${resourceHREF}", httpMode: 'GET', ignoreSslErrors: true, validResponseCodes: "200"
def jsonResponse = readJSON text: response.content
println(jsonResponse)
return jsonResponse.base_url
}
}
}