add make-containerized-build job

The job does not have any parameters yet, it only build for the master
branch.

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-04-01 13:49:29 +02:00
parent 9e2a7e0c8d
commit 538cdcdba4
4 changed files with 116 additions and 0 deletions

View File

@ -4,7 +4,53 @@
- Jenkins is hosted on [OpenShift in the CentOS CI](app_ci_centos_org)
- scripts and Jenkins jobs are hosted in the Ceph-CSI repository (ci/centos
branch)
- a Jenkins Pipeline is used to reserve bare metal system(s), and run jobs on
those systems
# Repository/Branch Structure
This is the `ci/centos` branch, where all the scripts for the Jenkins jobs are
maintained. The tests that are executed by the jobs are part of the normal
projects branches.
As an example, the `make-containerized-build` Jenkins job consists out of the
following files:
- `make-containerized-build.yaml` is a [Jenkins Job Builder](jjb) configuration
that describes the events when the job should get run and fetches the
`.groovy` file from the git repository/branch
- `make-containerized-build.groovy` is the [Jenkins Pipeline](pipeline) that
contains the stages for the Jenkins Job itself. In order to work with [the
bare-metal machines from the CentOS CI](centos_ci), it executes the following
stages:
1. dynamically allocate a Jenkins Slave (`node('cico-workspace')`) with tools
and configuration to request a bare-metal machine
1. checkout the `centos/ci` branch of the repository, which contains scripts
for provisioning and preparing the environment for running tests
1. reserve a bare-metal machine with `cico` (configured on the Jenkins Slave)
1. provision the reserved bare-metal machine with additional tools and
dependencies to run the test (see `prepare.sh` below)
1. run the test
1. as final step, return the bare-metal machine to the CentOS CI for other
users (it will be re-installed with a minimal CentOS environment again)
- `prepare.sh` installs dependencies for the test, and checks out the git
repository and branch (or Pull Request) that contains the commits to be
tested (and the test itself)
## Deploying the Jenkins Jobs
The Jenkins Jobs are described in Jenkins Job Builder configuration files and
Jenkins Pipelines. These need to be imported in the Jenkins instance before
they can be run. Importing is done with the `jenkins-jobs` command, which runs
in a `jjb` container. To build the container, and provide the configuration for
Jenkins Job Builder, see the [documentation in the `deploy/`
directory](deploy/README.md).
[ceph_csi_ci]: https://jenkins-ceph-csi.apps.ci.centos.org
[app_ci_centos_org]: https://console.apps.ci.centos.org:8443/console/project/ceph-csi
[jjb]: https://jenkins-job-builder.readthedocs.io/en/latest/index.html
[pipeline]: https://docs.openstack.org/infra/jenkins-job-builder/project_pipeline.html
[centos_ci_hw]: https://wiki.centos.org/QaWiki/PubHardware

View File

@ -0,0 +1,44 @@
def cico_retries = 16
def cico_retry_interval = 60
def ci_git_repo = 'https://github.com/ceph/ceph-csi'
def ci_git_branch = 'ci/centos'
node('cico-workspace') {
// environment (not?) set by Jenkins, or not?
environment {
GIT_REPO = 'https://github.com/ceph/ceph-csi'
GIT_BRANCH = 'master'
}
stage('checkout ci repository') {
git url: "${ci_git_repo}",
branch: "${ci_git_branch}",
changelog: false
}
stage('reserve bare-metal machine') {
cico = sh(
script: "cico node get -f value -c hostname -c comment --retry-count ${cico_retries} --retry-interval ${cico_retry_interval}",
returnStdout: true
).trim().tokenize(' ')
env.CICO_NODE = "${cico[0]}.ci.centos.org"
env.CICO_SSID = "${cico[1]}"
}
try {
stage('prepare bare-metal machine') {
sh 'scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ./prepare.sh root@${CICO_NODE}:'
sh 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${CICO_NODE} ./prepare.sh --workdir=/opt/build --gitrepo=${GIT_REPO} --branch=${GIT_BRANCH}'
}
stage('build') {
sh 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${CICO_NODE} "cd /opt/build && make containerized-build CONTAINER_CMD=podman"'
}
}
finally {
stage('return bare-metal machine') {
sh 'cico node done ${CICO_SSID}'
}
}
}

View File

@ -0,0 +1,19 @@
---
- job:
name: make-containerized-build
project-type: pipeline
sandbox: true
pipeline-scm:
scm:
- git:
url: https://github.com/ceph/ceph-csi
branches:
- ci/centos
script-path: make-containerized-build.groovy
lightweight-checkout: true
triggers:
- github-pull-request:
admin-list:
- nixpanic
org-list:
- ceph

7
prepare.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
set -x
yum -y install git podman
git clone --single-branch --branch=master https://github.com/ceph/ceph-csi /opt/build