The pipeline: Jenkinsfile
The minimal content for the Jenkinsfile
is as follows:
@Library(['github.com/indigo-dc/jenkins-pipeline-library@release/2.1.0']) _
def projectConfig
pipeline {
agent any
stages {
stage('SQA baseline dynamic stages') {
steps {
script {
projectConfig = pipelineConfig()
buildStages(projectConfig)
}
}
post {
cleanup {
cleanWs()
}
}
}
}
}
The pipeline explained
The pipeline loads the jenkins-pipeline-library in the first place:
@Library(['github.com/indigo-dc/jenkins-pipeline-library@release/2.1.0']) _
and only requires the definition of a single stage that will be in charge of:
Parsing the
.sqa/config.yml
file:
projectConfig = pipelineConfig()
Build one stage per criteria found in
sqa_criteria
setting in the.sqa/config.yml
file:
buildStages(projectConfig)
Customize the configurations for the pipeline job (advanced options)
The library expects by default the presence of the configuration file in
.sqa/config.yml
. Also other parameters that are set by default from triggered job can be overriden. For current version the supported configurations are configFile, baseRepository, baseBranch, credentialsId, validatorDockerImage and scmConfigs. All of this arguments are optional and don’t have any dependency.
Note
scmConfigs corresponds to extensions options for Jenkins SCM step. In current version is only supported LocalBranch extension for GitSCM class.
As an example using all available options, the call to pipelineConfig can be changed to the following:
projectConfig = pipelineConfig(
configFile: '<alternative_path>',
baseRepository: '<git repository url>',
baseBranch: '<branch or tag name>',
credentialsId: '<Jenkins credential id>',
validatorDockerImage: '<jpl-validator docker image>',
scmConfigs: [ localBranch: '<local branch name>' ]
)
Note
If <local branch name> value is an empty string or “**”, then the branch name is computed from the remote branch without the origin. Example: - origin/master will be checked out to local branch named master - origin/feature/new the same into local branch named feature/new
If given a different value from previous ones, it will checkout into a new branch with provided name.