meta-scripts/Jenkinsfile.deploy

74 lines
1.8 KiB
Groovy

// one job per arch (for now) that copies built images to the arch-specific namespaces
properties([
disableConcurrentBuilds(),
disableResume(),
durabilityHint('PERFORMANCE_OPTIMIZED'),
rateLimitBuilds([
count: 1,
durationName: 'hour',
userBoost: true,
]),
pipelineTriggers([
upstream('meta'),
cron('H H/6 * * *'), // run every few hours whether we "need" it or not
]),
])
env.BASHBREW_ARCH = env.JOB_NAME.split('/')[-1].minus('deploy-') // "windows-amd64", "arm64v8", etc
node('multiarch-' + env.BASHBREW_ARCH) { ansiColor('xterm') {
stage('Checkout') {
checkout(scmGit(
userRemoteConfigs: [[
url: 'https://github.com/docker-library/meta.git',
name: 'origin',
]],
branches: [[name: '*/subset']], // TODO back to main
extensions: [
submodule(
parentCredentials: true,
recursiveSubmodules: true,
trackingSubmodules: true,
),
cleanBeforeCheckout(),
cleanAfterCheckout(),
[$class: 'RelativeTargetDirectory', relativeTargetDir: 'meta'],
],
))
}
dir('meta') {
stage('Generate') {
sh '''#!/usr/bin/env bash
set -Eeuo pipefail -x
jq -L.scripts '
include "deploy";
arch_tagged_manifests(env.BASHBREW_ARCH)
| deploy_objects[]
' builds.json | tee deploy.json
'''
}
withCredentials([
string(credentialsId: 'dockerhub-public-proxy', variable: 'DOCKERHUB_PUBLIC_PROXY'),
string(credentialsId: 'dockerhub-public-proxy-host', variable: 'DOCKERHUB_PUBLIC_PROXY_HOST'),
]) {
stage('Deploy') {
sh '''#!/usr/bin/env bash
set -Eeuo pipefail -x
(
cd .scripts
# TODO make a helper to build binaries correctly/consistently 🙃
if ./.any-go-nt.sh bin/deploy; then
./.go-env.sh go build -trimpath -o bin/deploy ./cmd/deploy
fi
)
.scripts/bin/deploy < deploy.json
'''
}
}
}
} }