From 5d2f6b433f32a16c80c8f006e4b88015bb8cccb1 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Sun, 25 Jun 2023 15:37:23 -0700 Subject: [PATCH] use our library --- Jenkinsfile | 53 +---------------------------------------------------- 1 file changed, 1 insertion(+), 52 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3ad49d98..f1465e93 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,55 +1,4 @@ -def buildAndPush() { - // env.ARCH is the system architecture. some apps can be generic (amd64, arm64), - // but apps that compile for specific hardware (like web3-proxy) will need more specific tags (amd64_epyc2, arm64_graviton2, intel_xeon3, etc.) - // env.BRANCH_NAME is set to the git branch name by default - // env.REGISTRY is the repository url for this pipeline - // env.GIT_SHORT is the git short hash of the currently checked out repo - // env.LATEST_BRANCH is the branch name that gets tagged latest - - // TODO: check that this system actually matches the given arch - sh '''#!/bin/bash - set -eux -o pipefail - - [ -n "$ARCH" ] - [ -n "$BRANCH_NAME" ] - [ -n "$REGISTRY" ] - [ -n "$GIT_SHORT" ] - [ -n "$LATEST_BRANCH" ] - - # deterministic mtime on .git keeps Dockerfiles that do 'ADD . .' or similar - # without this, the build process always thinks the directory has changes - git restore-mtime - touch -t "$(git show -s --date=format:'%Y%m%d%H%M.%S' --format=%cd HEAD)" .git - - function buildAndPush { - image=$1 - buildcache=$2 - - buildctl build \ - --frontend=dockerfile.v0 \ - --local context=. \ - --local dockerfile=. \ - --output "type=image,name=${image},push=true" \ - --export-cache type=s3,region=us-east-2,bucket=llamarpc-buildctl-cache,name=${buildcache} \ - --import-cache type=s3,region=us-east-2,bucket=llamarpc-buildctl-cache,name=${buildcache} \ - ; - } - - BUILDCACHE="${REGISTRY}:buildcache_${ARCH}" - - # build and push a docker image tagged with the short git commit - buildAndPush "${REGISTRY}:git_${GIT_SHORT}_${ARCH}" "${BUILDCACHE}" - - # push an image tagged with the branch - # since buildAndPush just ran above, this should be very quick - # TODO: maybe replace slashes in the name with dashes or underscores - buildAndPush "${REGISTRY}:branch_${BRANCH_NAME}_${ARCH}" "${BUILDCACHE}" - - if [ "${BRANCH_NAME}" = "${LATEST_BRANCH}" ]; then - buildAndPush "${REGISTRY}:latest_${ARCH}" "${BUILDCACHE}" - fi - ''' -} +@Library('jenkins_lib@main') _ pipeline { agent any