Compare commits
2 Commits
0b73922b47
...
bci2-resou
| Author | SHA1 | Date | |
|---|---|---|---|
| 3d17d1bba4 | |||
| b98e6a99ae |
@@ -9,6 +9,8 @@ def call(args) {
|
|||||||
def schedule = args?.schedule
|
def schedule = args?.schedule
|
||||||
def defaultBranch = args?.defaultBranch
|
def defaultBranch = args?.defaultBranch
|
||||||
def pi = args?.pi
|
def pi = args?.pi
|
||||||
|
def resources = args?.resources
|
||||||
|
def buildArgs = args?.buildArgs
|
||||||
|
|
||||||
properties([
|
properties([
|
||||||
pipelineTriggers([cron(schedule ?: 'H H H * *')])
|
pipelineTriggers([cron(schedule ?: 'H H H * *')])
|
||||||
@@ -32,9 +34,6 @@ def call(args) {
|
|||||||
if (defaultBranch == null) {
|
if (defaultBranch == null) {
|
||||||
defaultBranch = 'main'
|
defaultBranch = 'main'
|
||||||
}
|
}
|
||||||
if (pi == null) {
|
|
||||||
pi = true
|
|
||||||
}
|
|
||||||
def repo = "${registry}/${project}/${name}"
|
def repo = "${registry}/${project}/${name}"
|
||||||
def full_name = "${repo}:${tag}"
|
def full_name = "${repo}:${tag}"
|
||||||
|
|
||||||
@@ -48,14 +47,15 @@ def call(args) {
|
|||||||
full_name: full_name,
|
full_name: full_name,
|
||||||
registry: registry,
|
registry: registry,
|
||||||
arch: arch,
|
arch: arch,
|
||||||
pi: pi,
|
resources: resources,
|
||||||
|
buildArgs: buildArgs,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parallel stages
|
parallel stages
|
||||||
|
|
||||||
runInPod(pi: false) {
|
runInPod {
|
||||||
container('buildah') {
|
container('buildah') {
|
||||||
withBuildahCreds(registry) {
|
withBuildahCreds(registry) {
|
||||||
if (archlist.size() > 1) {
|
if (archlist.size() > 1) {
|
||||||
@@ -96,14 +96,19 @@ def buildStage(args) {
|
|||||||
def full_name = args.full_name
|
def full_name = args.full_name
|
||||||
def registry = args.registry
|
def registry = args.registry
|
||||||
def arch = args.arch
|
def arch = args.arch
|
||||||
def pi = args.pi
|
def resources = args?.resources
|
||||||
|
def buildArgs = args?.buildArgs ?: []
|
||||||
|
|
||||||
runInPod(arch: arch, pi: pi) {
|
def build_command = "buildah build -t '${full_name}'"
|
||||||
|
buildArgs.each { build_command += "--build-arg '${it}'" }
|
||||||
|
build_command += ' .'
|
||||||
|
|
||||||
|
runInPod(arch: arch, resources: resources) {
|
||||||
checkout scm
|
checkout scm
|
||||||
|
|
||||||
container('buildah') {
|
container('buildah') {
|
||||||
withBuildahCreds(registry) {
|
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}"
|
sh "buildah push '${full_name}' oci-archive:\${PWD}/${escapeImageName(name)}-${arch}.tar:${full_name}"
|
||||||
stash name: arch, includes: "${escapeImageName(name)}-*.tar"
|
stash name: arch, includes: "${escapeImageName(name)}-*.tar"
|
||||||
}
|
}
|
||||||
@@ -111,23 +116,24 @@ def buildStage(args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def runInPod(block) {
|
||||||
|
runInPod(null, block)
|
||||||
|
}
|
||||||
|
|
||||||
def runInPod(args, block) {
|
def runInPod(args, block) {
|
||||||
def arch = args?.arch
|
def arch = args?.arch
|
||||||
def pi = args?.pi
|
def resources = args?.resources
|
||||||
if (pi == null) {
|
|
||||||
pi = true
|
|
||||||
}
|
|
||||||
|
|
||||||
def podTemplateYaml = libraryResource('podTemplate2.yaml')
|
def podTemplateYaml = libraryResource('podTemplate2.yaml')
|
||||||
if (pi) {
|
if (resources) {
|
||||||
def tmpl = readYaml(text: podTemplateYaml)
|
def tmpl = readYaml(text: podTemplateYaml)
|
||||||
def tolerations = tmpl['spec']['tolerations'] ?: []
|
tmpl.spec.containers.each { c ->
|
||||||
tolerations.push([
|
c.resources = c.resources ?: [:]
|
||||||
key: 'du5t1n.me/machine',
|
c.resources.putAll([
|
||||||
value: 'raspberrypi',
|
requests: (c.resources.requests ?: [:]) + resources,
|
||||||
effect: 'NoExecute',
|
limits: (c.resources.limits ?: [:]) + resources,
|
||||||
])
|
])
|
||||||
tmpl['spec']['tolerations'] = tolerations
|
}
|
||||||
podTemplateYaml = writeYaml(data: tmpl, returnText: true)
|
podTemplateYaml = writeYaml(data: tmpl, returnText: true)
|
||||||
}
|
}
|
||||||
podTemplate(
|
podTemplate(
|
||||||
|
|||||||
Reference in New Issue
Block a user