A minimal configuration
We will use the fictional repository https://github.com/myorg/myrepo. The following steps set up the minimum layout:
Clone the repo
$ export MY_REPO=https://github.com/myorg/myrepo
$ git clone $MY_REPO
A good practice is to add the changes herein described in an individual branch, so not directly in the production –usually
master
– branch. In this example we will usesetup_jenkins-pipeline-library
as follows:
$ cd $MY_REPO
$ git checkout -b setup_jenkins-pipeline-library
We will now create the following directory structure within the code repository, as required by the library (be sure to read Layout section):
|-- .sqa | |-- config.yml | |-- docker-compose.yml |-- Jenkinsfile
3.1. Create the main
.sqa
folder:$ mkdir .sqa
3.2. Create the initial content of the main configuration file,
.sqa/config.yml
, with the description of your repository (see The configuration file: config.yml section):$ cat <<EOF > .sqa/config.yml config: project_repos: myrepo: repo: 'https://github.com/myorg/myrepo' EOF
3.3. Create the
.sqa/docker-compose.yml
. For the time being, we will only specify the version required by the library (i.e.3.6
), later on we will add the service definitions (see The services: docker-compose.yml section):$ cat <<EOF > .sqa/docker-compose.yml version: "3.6" EOF
3.4. In the root path of the code repository, create the
Jenkisfile
, file required by Jenkins. In order to make it work with the jenkins-pipeline-library, at least the following content must be present (see The pipeline: Jenkinsfile section):$ cat <<EOF > Jenkinsfile @Library(['github.com/indigo-dc/jenkins-pipeline-library@stable/2.0.0']) _ def projectConfig pipeline { agent any stages { stage('SQA baseline dynamic stages') { steps { script { projectConfig = pipelineConfig() buildStages(projectConfig) } } post { cleanup { cleanWs() } } } } } EOF
Commit & push the layout files:
$ git add .sqa Jenkinsfile
$ git commit -m "Initial setup of jenkins-pipeline-library files"
Now that we have the skeleton with an initial version of the three relevant
files, let’s add our checks through the sqa_criteria
setting. We will see
how to do that in the next section.