STEP 1- Click on manage jenkins on the left side menu.
STEP 2- Click on configure system. Scroll down until you find the Global Pipeline Libraries section.
STEP 3- Under the Library section, configure values as below.
@Library ("test-library@branch") _
@Library ("test-library@master") _
advancedPipeline(scmUrl: 'https://github.com/Burakolum/jenkins-Library.git',
registry: "burakolum/burak",
registryCredential: 'burakolum-dockerhub',
dockerImage: '' )
Each of your custom steps is a different .groovy file inside your vars/ directory.
Create a file for your custom step.For example,
buildDocker.groovy
#!/usr/bin/env groovy
def call(String registry){
sh 'sudo docker build -t $registry:$BUILD_NUMBER . '
sh 'docker tag $registry:$BUILD_NUMBER docker.io/$registry:$BUILD_NUMBER'
}
You can also add parameters to your method - the example above has one parameter called registry
.
To use the shared library in a pipeline, you add @Library('your-library-name') to the top of your pipeline definition
if you would like to see other custom steps you could look vars directory