Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for building Agent containers to the CI #3109

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion agent/containers/images/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ _PBENCH_REPO_NAME = pbench-${_LOCAL_MAJORMINOR}${_TEST_SUFFIX}
# By default we use the pbench Quay.io organization for the image
# repository. You can override this default using an environment
# variable as appropriate.
IMAGE_REPO = docker://quay.io/pbench
IMAGE_REPO ?= docker://quay.io/pbench
IMAGE_TAG ?= latest

# Convenience reference to the repo template in the pbench tree.
# Not intended to be overridden with an environment variable.
Expand Down Expand Up @@ -293,6 +294,15 @@ centos-7-base.Dockerfile: _PKGMGR = yum
# Push local images for the given tag and distribution.
#-

# Special push target for the CI which pushes a full set of the various container
# images for the distribution to the specified registry with the specified tag.
$(_DEFAULT_DISTROS:%=%-push-ci): %-push-ci:
for image in base tools tool-meister tool-data-sink workloads all; do \
dbutenhof marked this conversation as resolved.
Show resolved Hide resolved
buildah push \
localhost/pbench-agent-$${image}-${*}:${_LOCAL_GIT_HASH} \
${IMAGE_REPO}/pbench-agent-$${image}-${*}:${IMAGE_TAG} ; \
done

define _PUSH_RULE
%-push-$(1): %-tags.lis
./push ${IMAGE_REPO} $$* $(1)
Expand Down Expand Up @@ -371,3 +381,5 @@ all-tags: pkgmgr-clean $(_DEFAULT_DISTROS:%=%-tags.lis)

clean:
rm -f *.Dockerfile *.repo *.yml *-tags.lis pbench-agent-*-*.noarch.rpm.*

.PHONY: all baseimage clean everything push repofix tds tm
55 changes: 33 additions & 22 deletions jenkins/Pipeline.gy
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,16 @@ pipeline {
PY_COLORS=0
TERM='dumb'

// The remaining variables are for `jenkins/run-server-func-tests`.

PODMAN_INTERNAL=credentials('12b404ca-3036-4960-9929-979148b9e49a')
KEYCLOAK_CLIENT_SECRET=credentials('5cf0304d-8a00-48a4-ade5-9f59cb37ba68')
PB_CONTAINER_REG=credentials('c3e2d737-0e56-4c1e-a945-d86bc644384c')

// Configuration for remote container registries
PB_CI_REGISTRY=credentials('c3e2d737-0e56-4c1e-a945-d86bc644384c')
PB_CI_REG_CRED=credentials('12b404ca-3036-4960-9929-979148b9e49a')
PB_ORG_NAME="pbench"

// 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;
// otherwise we set it to the branch name (e.g., `main`).
PB_IMAGE_TAG="${env.CHANGE_ID ?: env.BRANCH_NAME}"
PB_SERVER_IMAGE_NAME="pbench-server-ci"
// 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
// the Server Pod name, based on the image tag, so that we don't
// interfere with other pods on this executor.
PB_SERVER_IMAGE_TAG="""${sh(
returnStdout: true,
script: 'echo ${CHANGE_ID:-${BRANCH_NAME}}'
)}""".trim()

PB_DASHBOARD_DIR="${WORKSPACE}/dashboard/build/"
}
stages {
stage('Agent Python3.6 Check') {
Expand All @@ -50,14 +40,35 @@ pipeline {
}
}
stage('Build the Pbench Server Container') {
environment {
KEYCLOAK_CLIENT_SECRET=credentials('5cf0304d-8a00-48a4-ade5-9f59cb37ba68')
PB_SERVER_IMAGE_TAG="${PB_IMAGE_TAG}"
RPM_PATH="${WORKSPACE_TMP}/rpmbuild/RPMS/noarch/pbench-server-*.rpm"
}
steps {
sh 'buildah login -u="${PODMAN_INTERNAL_USR}" -p="${PODMAN_INTERNAL_PSW}" ${PB_CONTAINER_REG}'
sh 'RPM_PATH=${WORKSPACE_TMP}/rpmbuild/RPMS/noarch/pbench-server-*.rpm bash -ex ./server/pbenchinacan/container-build-ci.sh'
sh 'buildah push localhost/pbench-server:${PB_SERVER_IMAGE_TAG} ${PB_CONTAINER_REG}/${PB_ORG_NAME}/pbench-server:${PB_SERVER_IMAGE_TAG}'
sh 'buildah push localhost/${PB_SERVER_IMAGE_NAME}:${PB_SERVER_IMAGE_TAG} ${PB_CONTAINER_REG}/${PB_ORG_NAME}/${PB_SERVER_IMAGE_NAME}:${PB_SERVER_IMAGE_TAG}'
sh 'buildah login -u="${PB_CI_REG_CRED_USR}" -p="${PB_CI_REG_CRED_PSW}" ${PB_CI_REGISTRY}'
sh 'bash -ex ./server/pbenchinacan/container-build-ci.sh'
sh 'buildah push localhost/pbench-server:${PB_IMAGE_TAG} ${PB_CI_REGISTRY}/${PB_ORG_NAME}/pbench-server:${PB_IMAGE_TAG}'
sh 'buildah push localhost/${PB_SERVER_IMAGE_NAME}:${PB_IMAGE_TAG} ${PB_CI_REGISTRY}/${PB_ORG_NAME}/${PB_SERVER_IMAGE_NAME}:${PB_IMAGE_TAG}'
}
}
stage('Build the Pbench Agent Containers') {
environment {
PB_AGENT_DISTRO="fedora-36"
}
steps {
sh 'buildah login -u="${PB_CI_REG_CRED_USR}" -p="${PB_CI_REG_CRED_PSW}" ${PB_CI_REGISTRY}'
sh '/usr/bin/python3 -m pip install --user jinja2-cli'
sh 'make -C agent/containers/images CI_RPM_ROOT=${WORKSPACE_TMP} clean ${PB_AGENT_DISTRO}-everything'
sh 'make -C agent/containers/images IMAGE_REPO=${PB_CI_REGISTRY}/${PB_ORG_NAME} IMAGE_TAG=${PB_IMAGE_TAG} ${PB_AGENT_DISTRO}-push-ci'
}
}
stage('Deploy server and run functional tests') {
environment {
PB_CONTAINER_REG="${PB_CI_REGISTRY}"
PB_DASHBOARD_DIR="${WORKSPACE}/dashboard/build/"
PB_SERVER_IMAGE_TAG="${PB_IMAGE_TAG}"
}
steps {
sh 'jenkins/run-server-func-tests --cleanup'
}
Expand Down