| |
@@ -0,0 +1,68 @@
|
| |
+ # This file defines a Jenkins job that periodically rebuilds the container
|
| |
+ # images used for running unit tests.
|
| |
+ #
|
| |
+ # To use it, install jenkins-job-builder via pip and create a configuration
|
| |
+ # file with this content:
|
| |
+ #
|
| |
+ # [jenkins]
|
| |
+ # user=<your jenkins ID, displayed on People page in UI>
|
| |
+ # password=<API token created in the Jenkins UI>
|
| |
+ # url=https://jenkins-fedora-infra.apps.ocp.cloud.ci.centos.org/
|
| |
+ #
|
| |
+ # Then run the tool like this:
|
| |
+ #
|
| |
+ # $ jenkins-jobs --conf jenkins-jobs.ini update tests/jenkins-image-rebuild-job.yaml
|
| |
+ #
|
| |
+ # The job expects a credential with pungi-quay-io-push-token to exist in
|
| |
+ # Jenkins. It should be a secret file with login information for the account
|
| |
+ # pushing the image.
|
| |
+ - job:
|
| |
+ name: pungi-test-image-rebuild
|
| |
+ project-type: freestyle
|
| |
+ description: Rebuild container images for running Pungi unit tests and push them to quay.io
|
| |
+ concurrent: false
|
| |
+ node: cico-workspace
|
| |
+ logrotate:
|
| |
+ numToKeep: 20
|
| |
+ triggers:
|
| |
+ - timed: '@weekly'
|
| |
+ wrappers:
|
| |
+ - credentials-binding:
|
| |
+ - file:
|
| |
+ credential-id: pungi-quay-io-push-token
|
| |
+ variable: QUAY_AUTHFILE
|
| |
+ builders:
|
| |
+ - shell: |
|
| |
+ # Set up Duffy node
|
| |
+ set +x
|
| |
+ SESSION="$(duffy client --url https://duffy.ci.centos.org/api/v1 --auth-name fedora-infra --auth-key "$CICO_API_KEY" request-session pool=virt-ec2-t2-centos-9s-x86_64,quantity=1)"
|
| |
+ DUFFY_SESSION_ID="$(jq -r <<<"$SESSION" ".session.id")"
|
| |
+ trap 'set +x && echo "SHUTTING DOWN DUFFY NODE" && duffy client --url https://duffy.ci.centos.org/api/v1 --auth-name fedora-infra --auth-key "$CICO_API_KEY" retire-session "$DUFFY_SESSION_ID" >/dev/null' EXIT
|
| |
+
|
| |
+ # Set up environment
|
| |
+ remote_dir=/tmp/$JENKINS_AGENT_NAME
|
| |
+ hostname=$(jq <<<"$SESSION" -r '.session.nodes[0].hostname')
|
| |
+
|
| |
+ echo "duffy session id: $DUFFY_SESSION_ID hostname: $hostname"
|
| |
+
|
| |
+ # Prepare job script
|
| |
+ cat >job.sh <<EOF
|
| |
+ set -x
|
| |
+ dnf install -y git podman skopeo
|
| |
+ git clone https://pagure.io/pungi.git
|
| |
+ cd pungi
|
| |
+ podman build -t pungi-test -f tests/Dockerfile-test
|
| |
+ podman build -t pungi-test-py2 -f tests/Dockerfile-test-py2
|
| |
+ skopeo copy --authfile=$remote_dir/authfile docker://quay.io/exd-guild-compose/pungi-test:latest docker://quay.io/exd-guild-compose/pungi-test:previous
|
| |
+ skopeo copy --authfile=$remote_dir/authfile docker://quay.io/exd-guild-compose/pungi-test-py2:latest docker://quay.io/exd-guild-compose/pungi-test-py2:previous
|
| |
+ podman push --authfile=$remote_dir/authfile pungi-test:latest docker://quay.io/exd-guild-compose/pungi-test:latest
|
| |
+ podman push --authfile=$remote_dir/authfile pungi-test-py2:latest docker://quay.io/exd-guild-compose/pungi-test-py2:latest
|
| |
+ EOF
|
| |
+
|
| |
+ set -x
|
| |
+ ssh -o StrictHostKeyChecking=no root@$hostname mkdir $remote_dir
|
| |
+ scp job.sh root@$hostname:$remote_dir
|
| |
+ scp $QUAY_AUTHFILE root@$hostname:$remote_dir/authfile
|
| |
+
|
| |
+ # Run the actual workload
|
| |
+ ssh root@$hostname sh $remote_dir/job.sh
|
| |
This is definition for a jenkins job:
https://jenkins-fedora-infra.apps.ocp.cloud.ci.centos.org/job/pungi-test-image-rebuild/21/console
The job will run weekly, pull the latest dockerfiles from git, build the test images and push them to quay.io. The previous image is tagged so that there's a way to roll back.