84 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			Groovy
		
	
	
	
	
	
			
		
		
	
	
			84 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			Groovy
		
	
	
	
	
	
| #!groovy
 | |
| 
 | |
| def repository = "registry.c.test-chamber-13.lan"
 | |
| def repositoryCreds = "harbor-repository-creds"
 | |
| 
 | |
| def workspace
 | |
| def dockerFile
 | |
| def ubiOS
 | |
| def ubiImages
 | |
| 
 | |
| def label = "kubernetes-${UUID.randomUUID().toString()}"
 | |
| def templateName = "pipeline-worker"
 | |
| pipeline {
 | |
|     agent {
 | |
|         kubernetes {
 | |
|             yaml functions.podYaml(
 | |
|                 repo: repository,
 | |
|                 templateName: templateName,
 | |
|                 kaniko: true
 | |
|             )
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     stages {
 | |
|         stage ('Initalize Jenkins') {
 | |
|             steps {
 | |
|                 script {
 | |
|                     workspace = pwd()
 | |
|                     ubiOS = ["9"]
 | |
|                     ubiImages = ["ubi-minimal", "ubi"]
 | |
|                     
 | |
|                     writeFile(file: workspace + "/test-chamber-13.lan.root.crt", text: functions.getCurrentRootCA())
 | |
|                     writeFile(file: workspace + "/test-chamber-13.lan.ret.root.crt", text: functions.getRetiredRootCA())
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         stage ('Build Images') {
 | |
|             steps {
 | |
|                 script {
 | |
|                     for (rhOS in ubiOS) {
 | |
|                         for (image in ubiImages) {
 | |
|                             stage ("Build ubi${rhOS}:${image}") {
 | |
|                                 def updateCmd
 | |
|                                 if (image == "ubi-minimal") {
 | |
|                                     updateCmd = "microdnf"
 | |
|                                 } else {
 | |
|                                     updateCmd = "dnf"
 | |
|                                 }
 | |
|                                 dockerFile = """FROM registry.access.redhat.com/ubi${rhOS}/${image}:latest
 | |
| 
 | |
| LABEL org.opencontainers.image.authors="The_Spider <spider@smoothnet.org>"
 | |
| LABEL org.opencontainers.image.title="ubi${rhOS}/${image}"
 | |
| LABEL org.opencontainers.image.description="Docker container for RHEL-UBI"
 | |
| LABEL org.opencontainers.image.base.name="registry.access.redhat.com/ubi${rhOS}/${image}:latest"
 | |
| 
 | |
| COPY test-chamber-13.lan.root.crt test-chamber-13.lan.ret.root.crt /etc/pki/ca-trust/source/anchors/
 | |
| 
 | |
| RUN update-ca-trust extract && \\
 | |
|     ${updateCmd} update -y && \\
 | |
|     ${updateCmd} clean all
 | |
| """
 | |
|                                 container ("kaniko") {
 | |
|                                     declarativeFunctions.buildContainerMultipleDestinations(
 | |
|                                         dockerFile: dockerFile,
 | |
|                                         repositoryAccess: [
 | |
|                                             [
 | |
|                                                 repository: repository,
 | |
|                                                 credentials: repositoryCreds
 | |
|                                             ],
 | |
|                                         ],
 | |
|                                         destination: [
 | |
|                                             "${repository}/library/rhubi/${image}:${rhOS}",
 | |
|                                         ]
 | |
|                                     )
 | |
|                                 }
 | |
|                             }
 | |
|                         }
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| } |