Compare commits
2 Commits
83d694d663
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 80de47047c | |||
| b98e6a99ae |
@@ -10,6 +10,7 @@ def call(args) {
|
||||
def defaultBranch = args?.defaultBranch
|
||||
def pi = args?.pi
|
||||
def resources = args?.resources
|
||||
def buildArgs = args?.buildArgs
|
||||
|
||||
properties([
|
||||
pipelineTriggers([cron(schedule ?: 'H H H * *')])
|
||||
@@ -47,13 +48,14 @@ def call(args) {
|
||||
registry: registry,
|
||||
arch: arch,
|
||||
resources: resources,
|
||||
buildArgs: buildArgs,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
parallel stages
|
||||
|
||||
runInPod() {
|
||||
runInPod {
|
||||
container('buildah') {
|
||||
withBuildahCreds(registry) {
|
||||
if (archlist.size() > 1) {
|
||||
@@ -95,13 +97,18 @@ def buildStage(args) {
|
||||
def registry = args.registry
|
||||
def arch = args.arch
|
||||
def resources = args?.resources
|
||||
def buildArgs = args?.buildArgs ?: []
|
||||
|
||||
def build_command = "buildah build -t '${full_name}'"
|
||||
buildArgs.each { build_command += " --build-arg '${it}'" }
|
||||
build_command += ' .'
|
||||
|
||||
runInPod(arch: arch, resources: resources) {
|
||||
checkout scm
|
||||
|
||||
container('buildah') {
|
||||
withBuildahCreds(registry) {
|
||||
sh "buildah build -t '${full_name}' ."
|
||||
sh build_command
|
||||
sh "buildah push '${full_name}' oci-archive:\${PWD}/${escapeImageName(name)}-${arch}.tar:${full_name}"
|
||||
stash name: arch, includes: "${escapeImageName(name)}-*.tar"
|
||||
}
|
||||
@@ -109,6 +116,10 @@ def buildStage(args) {
|
||||
}
|
||||
}
|
||||
|
||||
def runInPod(block) {
|
||||
runInPod(null, block)
|
||||
}
|
||||
|
||||
def runInPod(args, block) {
|
||||
def arch = args?.arch
|
||||
def resources = args?.resources
|
||||
@@ -118,13 +129,12 @@ def runInPod(args, block) {
|
||||
def tmpl = readYaml(text: podTemplateYaml)
|
||||
tmpl.spec.containers.each { c ->
|
||||
c.resources = c.resources ?: [:]
|
||||
c.resources.requests = c.resources.requests ?: [:]
|
||||
c.resources.limits = c.resources.limits ?: [:]
|
||||
c.resources.requests += resources
|
||||
c.resources.limits += resources
|
||||
c.resources.putAll([
|
||||
requests: (c.resources.requests ?: [:]) + resources,
|
||||
limits: (c.resources.limits ?: [:]) + resources,
|
||||
])
|
||||
}
|
||||
podTemplateYaml = writeYaml(data: tmpl, returnText: true)
|
||||
echo podTemplateYaml
|
||||
}
|
||||
podTemplate(
|
||||
yaml: podTemplateYaml,
|
||||
|
||||
Reference in New Issue
Block a user