Skip to content

Commit

Permalink
Groovy experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
webbnh committed Dec 10, 2022
1 parent 3d1c656 commit 259a8e2
Showing 1 changed file with 20 additions and 27 deletions.
47 changes: 20 additions & 27 deletions jenkins/Pipeline.gy
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,22 @@ pipeline {
PY_COLORS=0
TERM='dumb'

// Set the tag to the PR number (i.e., the Jenkins CHANGE_ID) if run for
// a PR; otherwise set it to the branch name (e.g., `main`). Set a
// shorthand for the Pbench Server image path, and set a variable for
// If we are executing for a PR, as opposed to executing for a branch
// like `main`, the CHANGE_ID will be defined to the PR number. If it
// is defined we'll use its value for the container image tag. to the PR number (i.e., the Jenkins
// CHANGE_ID) if run for a PR; otherwise we set it to the branch name
// (e.g., `main`). Set a shorthand for the Pbench Server image path, and set a variable for
// the Server Pod name, based on the image tag, so that we don't
// interfere with other pods on this executor.
PB_IMAGE_TAG="""${sh(
returnStdout: true,
script: 'echo ${CHANGE_ID:-${BRANCH_NAME}}'
).trim()}"""
// If we are building a branch, set up to push the Agent containers to
// the external repository; however, if we are building a Pull Request,
// set up to push the Agent containers to the internal repository.

PB_AGENT_DISTRO="fedora-36"
if (env.PB_IMAGE_TAG == env.BRANCH_NAME) {
// We are building a branch; set up to push the Agent containers to
// the external repository.
echo "Configuring for branch build, for branch \"${BRANCH_NAME}\""
PB_AGENT_CONTAINER_REG=${PB_EXTERNAL_CONTAINER_REG}
} else {
// We are building a Pull Request; set up to push the Agent
// containers to the internal repository.
echo "Configuring for PR build, for #${CHANGE_ID}."
PB_AGENT_CONTAINER_REG=${PB_INTERNAL_CONTAINER_REG}
}
PB_AGENT_CONTAINER_REG="${env.CHANGE_ID ? env.PB_INTERNAL_CONTAINER_REG : env.PB_EXTERNAL_CONTAINER_REG}"
PB_DASHBOARD_DIR="${WORKSPACE}/dashboard/build/"
PB_IMAGE_TAG="${env.CHANGE_ID ?: env.BRANCH_NAME}"
PB_POD_NAME="pbenchinacan_${PB_IMAGE_TAG}"
PB_SERVER_IMAGE=${PB_INTERNAL_CONTAINER_REG} + "/pbench/pbenchinacan-pbenchserver"
}
stages {
stage('Agent Python3.6 Check') {
Expand All @@ -62,18 +53,20 @@ pipeline {
steps {
sh 'buildah login -u="${PODMAN_INTERNAL_USR}" -p="${PODMAN_INTERNAL_PSW}" ${PB_INTERNAL_CONTAINER_REG}'
sh 'RPM_PATH=${WORKSPACE_TMP}/rpmbuild/RPMS/noarch/pbench-server-*.rpm bash -ex ./server/pbenchinacan/container-build.sh'
sh 'buildah push localhost/pbench-server:${PB_IMAGE_TAG} ${PB_SERVER_IMAGE}:${PB_IMAGE_TAG}'
sh 'buildah push localhost/pbench-server:${PB_IMAGE_TAG} ${PB_INTERNAL_CONTAINER_REG}/pbench/pbenchinacan-pbenchserver:${PB_IMAGE_TAG}'
}
}
stage('Log in to external container registry') {
// If we are using the external container registry, then we need to
// log in. If we are using the internal registry, we'll assume that
// the Pbench Server build which also uses it has already done so.
when { equals expected: env.PB_EXTERNAL_CONTAINER_REG, actual: env.PB_AGENT_CONTAINER_REG }
steps {
sh 'buildah login -u="${PODMAN_EXTERNAL_USR}" -p="${PODMAN_EXTERNAL_PSW}" ${PB_EXTERNAL_CONTAINER_REG}'
}
}
stage('Build the Pbench Agent Containers') {
steps {
// If we are using the external container registry, then we need
// to log in. If we are using the internal registry, we'll
// assume that the Pbench Server build which also uses it has
// already logged us in.
if (env.PB_AGENT_CONTAINER_REG == env.PB_EXTERNAL_CONTAINER_REG) {
sh 'buildah login -u="${PODMAN_EXTERNAL_USR}" -p="${PODMAN_EXTERNAL_PSW}" ${PB_EXTERNAL_CONTAINER_REG}'
}
sh 'make -C agent/containers/images clean ${PB_AGENT_DISTRO}-everything'
sh 'make -C agent/containers/images IMAGE_REPO=${PB_AGENT_CONTAINER_REG}/pbench IMAGE_TAG=${PB_IMAGE_TAG} ${PB_AGENT_DISTRO}-push-ci'
}
Expand Down

0 comments on commit 259a8e2

Please sign in to comment.