Skip to content

AnimalLogic/AL_shared_pipeline_presentation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AL_jenkins_pipeline_library

Global external library to be shared across all pipelines jobs

In order to share some common pipeline scripts, we use this common shared library Internally in Jenkins, this library is called AL

Every pipeline job will implicitly load this library from the master branch. At the top of pipeline jobs, you will see a line like

Loading library AL@master

All the files under the vars directory are exported as global objects using the filename.

Example: if you have files called rez.groovy and algit.groovy, then you will have those available to use in your pipeline scripts, for example

rez.functionName()
rez.atrribure 
algit.functionName()

Modifying pipeline shared library

In order to add/remove/modify pipeline scripts, it is highly advisable that you do that from a branch and go thru the code review process before merging the changes into master since that will affect all Jenkins pipeline jobs.

Create a branch of this repo and then, in your pipeline script, try it by adding the following lines:

@Library('LIBRARY_NAME@BRANCH_NAME') _
i.e
@Library('AL@DT1659_support_for_documentation') _

Note the library will accept any Git Reference, not just a a BRANCH_NAME for example it can be a tag a SHA or a Reference opearation (i.e HEAD^ to get previous commit )

TIPS

  • While developing it is quite useful to use the Replay function. This will let you modify the pipeline code in place and try it without saving it. This is accessible from http://hudson:8081/hudson/job/JOB_NAME/JOB_NUMBER/replay/
  • You can see the documentation of the global objects (including the one defined in this library) In this page http://hudson:8081/hudson/JOBNAME/pipeline-syntax/globals
  • Use the declarative pipeline linter to validate your Jenkinsfile
curl -X POST -F "jenkinsfile=<Jenkinsfile" http://hudson:8081/hudson/pipeline-model-converter/validate

Exteranl Pipeline documentation

See more about shared libraries here

About

Shared pipeline for Jenkins Meetup presentation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published