-
Connect this repository to your Jenkins shared library as described in
official documentation
. -
Write your Jenkins pipeline like:
To use library from
src/org
:#!/usr/bin/env groovy @Library('jenkins-shared-library') node('master') { CommonFunctions = new org.alx.commonFunctions() as Object // your pipeline code and call this object by 'CommonFunctions.<functionName>', e.g: CommonFunctions.cleanSshHostsFingerprints(env.IP_LIST.tokenize(' ')) // where IP_LIST is a space separated string IP list which is defined by pipeline // parameter IP_LIST }
To use GitLab related functions (e.g. runAnsible) you should set GitCredentialsID variable, which can be defined in
OrgAlxGlobals()
class:@Library('jenkins-shared-library') node('master') { // CommonFunctions assignment and cast should be placed before GlobalConstants CommonFunctions = new org.alx.commonFunctions() as Object GlobalConstants = new org.alx.OrgAlxGlobals() as Object // Then use constants from OrgAlxGlobals }
To use library from
vars
:@Library('jenkins-shared-library') // or @Library(['jenkins-shared-library', 'another-library']) _ // if you need to use several libraries. node('master') { // your pipeline code then example usage of unstashParameter: String fileInWorkspace = unstashParameter "JENKINS_PIPELINE_FILE_PARAMETER_NAME" // Output file content sh String.format('cat %s', fileInWorkspace) }
Please also keep in mind a differences between
vars
andsrc
folder organizations (read this article for details). -
Read
Groovydoc
in the comments of file(s) (e.g:src/org/alx/commonFunctions.groovy
) for details. -
(Optional) To use Git-related functions (e.g.
cloneGitToFolder()
,installAnsibleGalaxyCollections()
orrunAnsible()
) to clone from ssh URL you should set up GitCredentialsID variable incommonFunctions.groovy
.
-
Notifications
You must be signed in to change notification settings - Fork 0
Jenkins shared library.
License
alexanderbazhenoff/jenkins-shared-library
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Jenkins shared library.