Common functionality for ECDC Jenkins pipeline jobs, including parallel builds in containers and automated Conan package generation and upload.
This library assumes the following plugins are installed on the Jenkins server:
The following environment variables are assumed to be defined on build nodes:
- http_proxy
- https_proxy
- local_conan_server
The docker
label is used to select the build nodes where the pipeline will be run.
To make this library globally available in Jenkins, go to Manage Jenkins, Configure System, Global Pipeline Libraries and follow the instructions below:
- Click the Add button.
- Fill the Name field with the chosen name for the library. This name will be used to access the library in pipeline scripts (recommendation:
ecdc-pipeline
). - Set the Default version to a valid Git version identifier (e.g.
master
, a commit hash or tag). - Under Retrieval method, select Modern SCM.
- Under Source Code Management, select Git.
- Set Project Repository to
https://git.esss.dk/dm_group/jenkins-shared-library.git
(this repository is mirrored on the DMSC GitLab). - Click Save to save the changes.
See the commented sample Jenkinsfiles provided in the examples folder and the documentation at https://ess-dmsc.github.io/jenkins-shared-library/.
Assuming you have added the shared library globally to Jenkins using the name ecdc-pipeline
, add the following line to a Jenkinsfile to make the library available:
@Library('ecdc-pipeline')
To make library classes available in the pipeline, use import
:
import ecdcpipeline.ContainerBuildNode
import ecdcpipeline.PipelineBuilder
To upgrade the default build node container images, edit src/ecdcpipeline/DefaultBuildNodeImages.groovy.
To develop the library and run tests locally, you need Groovy. You can find out what version of Groovy Jenkins is using by clicking on Master under Build Executor Status and then going to the Script Console; enter println GroovySystem.version
and click Run to get the result.
You can run unit tests from the root directory of this repository with
groovy --classpath src:test test/ecdcpipeline/<file_name>.groovy
where <file_name>
must be substituted with a test file name (*Test.groovy).
The runtests.sh script is provided to run all unit tests in the test/ecdcpipeline directory. Note that it always returns 0, independently of the test results.
To create the documentation pages locally, run from the root of this repository
groovydoc -sourcepath src -d docs 'ecdcpipeline' '*.groovy'
To test changes to the library on Jenkins before merging to master, you can merge them to the test-library branch that is used in https://github.com/ess-dmsc/jenkins-shared-library-test.
Possibly not. If you know how to make it more proper Groovy-like and want to do it, make the changes and send a pull request.