Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Pipeline: How to add help for Global Shared Library

According to documentation, it should be possible to include *.txt file with help/documentation:

(root)
 +- src                     # Groovy source files
 |   +- org
 |       +- foo
 |           +- Bar.groovy  # for org.foo.Bar class
 +- vars
 |   +- foo.groovy          # for global 'foo' variable/function
 |   +- foo.txt             # help for 'foo' variable/function
 +- resources               # resource files (external libraries only)
 |   +- org
 |       +- foo
 |           +- bar.json    # static helper data for org.foo.Bar

...

The vars directory hosts scripts that define global variables accessible from Pipeline scripts. The basename of each *.groovy file should be a Groovy (~ Java) identifier, conventionally camelCased. The matching *.txt, if present, can contain documentation, processed through the system’s configured markup formatter (so may really be HTML, Markdown, etc., though the txt extension is required).

Unfortunately it hasn't worked for me by simply creating *.txt with some arbitrary content.

Am I missing something? Or does Global Shared Library doesn't shown documentation in usual Jenkins places: enter image description here

like image 244
luka5z Avatar asked Dec 15 '16 10:12

luka5z


People also ask

What is a Jenkins shared library and how it is useful?

What is a Shared Library in Jenkins? A shared library is a collection of independent Groovy scripts which you pull into your Jenkinsfile at runtime. The best part is, the Library can be stored, like everything else, in a Git repository. This means you can version, tag, and do all the cool stuff you're used to with Git.

How does Jenkins Pipeline define global variable?

To access the Jenkins environment variables in a pipeline, you can use the env object, eg. env.BUILD_NUMBER will give the current build number of a pipeline. The reference to Jenkins pipeline environment variables is made by surrounding it by ${} in the following way: ${env.BUILD_NUMBER}

How to use shared libraries inside of a pipeline in Jenkins?

In order to use shared libraries inside of a pipeline in Jenkins we need to configure the library. Open up the Jenkins instance and navigate to Manage Jenkins -> Configure System. Scroll down until you locate the Global Pipeline Libraries section. Enter the relevant information as it pertains to your Git repository and checkout details:

How do I set up a global library in Jenkins?

Open up the Jenkins instance and navigate to Manage Jenkins -> Configure System. Scroll down until you locate the Global Pipeline Libraries section. Enter the relevant information as it pertains to your Git repository and checkout details: Configuring a Global Shared Library in Jenkins.

How to configure global pipeline scripts for a Jenkins instance?

Seems like there is a way to configure "global pipeline scripts" for a jenkins instance. The documentation says the configuration is "Manage Jenkins » Configure System » Global Pipeline Libraries". However, the Jenkins 2.7.2 instance doesn't have "Global Pipeline Libraries" configuration.

How to add GitHub shared library Repo to Jenkins?

Add Github Shared Library Repo to Jenkins. Now that we have a basic git checkout library ready lets add it to Jenkins configurations. Step 1: Go to Manage Jenkins –> Configure System. Step 2: Find the Global Pipeline Libraries section and add your repo details and configurations as shown below.


1 Answers

Please note that the PipelineSyntax/Global Variables Reference page is ONLY updated when the pipeline's run is successful. And therefore ONLY for this pipeline (and not any others).

Here's a link!

like image 58
Mariela Daventini Avatar answered Oct 17 '22 01:10

Mariela Daventini