Last active
December 3, 2021 21:02
-
-
Save scoheb/83d89cddec17ca9a637ae599124eb89f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.redhat.cpaas.pipeline.actuators.IndexImagesCreator | |
import com.redhat.cpaas.pipeline.model.ActuatorData | |
import com.redhat.cpaas.pipeline.model.MSAddonImageSet | |
import com.redhat.cpaas.pipeline.BrewUtils; | |
import com.redhat.cpaas.pipeline.CIMessageFactory | |
import com.redhat.cpaas.pipeline.CIMessageFromTest | |
import com.redhat.cpaas.pipeline.CIMessageGreenwave | |
String getNVR(String nvrOverride) { | |
if (nvrOverride != "") { return nvrOverride } | |
CIMessageFromTest ciMessage = CIMessageFactory.getCIMessageFromBuild(currentBuild) | |
if (!(ciMessage instanceof CIMessageGreenwave)) { | |
throw new IllegalStateException("Received CIMessage is not an instance of CIMessageGreewave") | |
} | |
List nvrs = ciMessage.getNVRs() | |
if (nvrs.size() != 1) { | |
throw new IllegalStateException("Expected a single NVR, found ${nvrs.size()}") | |
} | |
return nvrs[0] | |
} | |
runMsReleaseActuatorPipeline(params.PRODUCT_CONFIG_DIR) { | |
timeout(time: 180, unit: "MINUTES") { | |
if (params.NVR_OVERRIDE) { | |
it.withLoaderNode { | |
if (!greenwaveResult(params.NVR_OVERRIDE, "https://greenwave.engineering.redhat.com/api/v1.0", [:], 30, 10, "cp_managed_service")) { | |
error("NVR: " + params.NVR_OVERRIDE + " did not pass Greenwave cp_managed_service decision context. Exiting") | |
} | |
} | |
} | |
it.runActuators( | |
"Regenerate Bundle, Create Index Images and Mirror Content", | |
[new IndexImagesCreator(nvrOverride: params.NVR_OVERRIDE)] | |
) | |
def triggeredBy = null | |
it.withLoaderNode { | |
BrewUtils brewUtils = new BrewUtils() | |
String nvr = getNVR(params.NVR_OVERRIDE) | |
Map buildInfo = brewUtils.getBuild(nvr, true) | |
triggeredBy = buildInfo.extra?.custom_user_metadata?.automation_triggered_by | |
// need to handle missing value -> null | |
echo "This pipeline was deemed as being triggered by ${triggeredBy}" | |
} | |
ActuatorData actuatorsData = it.lastRunActuatorsResultData | |
stage('Sign Content') { | |
for(img in ( | |
actuatorsData.destinationImages | |
+ actuatorsData.indexImages | |
+ actuatorsData.relatedImages | |
) | |
) { | |
Map<String, String> signParams = [ | |
"manifestDigest": img["digest"], | |
"dockerReference": img["name"], | |
"containerRepo": img["namespace"], | |
"requestedBy": triggeredBy | |
] | |
signContainerImage(signParams) | |
} | |
} | |
stage('Create Managed Tenants MR') { | |
createAddonImageSet( | |
MSAddonImageSet.createImageSet( | |
it.cpaasConfig.getProductId(), | |
actuatorsData.indexImages[0]["name"], | |
actuatorsData.destinationImages[0]["name"], | |
actuatorsData.relatedImages.collect { img -> | |
img["name"] | |
} | |
) | |
) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment