Skip to content

Burkoz/jenkins-Library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

How To Use Shared Libraries In A Jenkins Pipeline?

Configure Shared Library in Jenkins

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

Referring Jenkins Shared Library from Pipeline

@Library ("test-library@branch") _

Example

@Library ("test-library@master") _

advancedPipeline(scmUrl: 'https://github.com/Burakolum/jenkins-Library.git',
                   registry: "burakolum/burak",
                   registryCredential: 'burakolum-dockerhub',
                   dockerImage: '' )

Also, can add your custom steps

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.

customstep
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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages