Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update shared-libraries #366

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Ravi-Theja-pallikonda
Copy link

@Ravi-Theja-pallikonda Ravi-Theja-pallikonda commented Nov 19, 2024

How to Create a Shared Library in Jenkins

  1. navigate to manage Jenkins
  2. Then navigate to System
  3. Go to Global Trusted Pipeline Libraries

Fields to fill:
Name: Name for shared library
Default Version: main (main branch Git)
Retrieval Method: Modern SCM
source Code Management: git
credentials: Give credentials if your repo is private, otherwise set it to none
Project Repository: Url of your source code repository
Save the changes.

NOTE:
. By Default Jenkins will look for the vars folder in your repo for SharedLibraries
. This should only be done once as long as repository remains the same

How to call your shared library in your jenkinsFile

Syntax:
Example groovy script:

@Library("shared-lib") _ ----------> This Function should be called at the starting of the groovy script to invoke shared libraries
pipeline {
agent any
stages {
stage('Hello') {
steps {
helloWorld() ---------> Your Shared library name in vars folder in your repo (eg:helloWorld.groovy)
}
}
}
}

@Ravi-Theja-pallikonda
Copy link
Author

Hi abhishek,
Just added a written version of your video about shared-libraries. Thought it might be helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant