Questions tagged [jenkins-shared-libraries]

jenkins-shared-libraries is about the global shared libraries you're able to use in jenkins on conjunction with the Jenkins pipeline plugin (formerly known as workflow plugin).

jenkins-shared-libraries is about the global shared libraries you're able to use in jenkins on conjunction with the Jenkins pipeline plugin (formerly known as workflow plugin). See also: https://jenkins.io/doc/book/pipeline/shared-libraries/

136 questions
19
votes
2 answers

Shared libraries "vars" folder structure - can I add subfolders?

From Extending with Shared Libraries - Directory structure I created a shared library where I have multiple *.groovy files implementing global variables in the vars folder. Can I add subfolders to vars to organize better my files? I tried, with no…
JosephS
  • 744
  • 5
  • 22
16
votes
3 answers

Jenkins shared library with intellij

I started implement Jenkins shared libraries and trying to write my jenkinsfile with intellij as my ide. How do I get functions from the shared lib repository to the other repository which holds the jenkins file inside it. Just to clarify things are…
14
votes
3 answers

Jenkins Shared Library src class - unable to resolve class

I am looking for some guidance on the design of a Jenkins Shared Library class. Using global vars as shared library is working fine but everytime I define a class in src/ and I want to import it, I get the error unable to resolve class. This is my…
11
votes
1 answer

Jenkins Pipeline - Call functions in shared jar

So here is my project setup A separate groovy project Multiple pipelines All the pipeline scripts refer to the shared groovy project. I went through the shared libraries and all of the needs to be registered in Jenkins global configuration. Is…
PrabhaT
  • 858
  • 3
  • 10
  • 22
9
votes
3 answers

Importing map variable to Jenkinsfile environment stage

My project has many common variables for many other projects, so I use Jenkins Shared Library and created a vars/my_vars.groovy file where I defined my variables and return Map of them: class my_vars { static Map varMap = [:] static def…
9
votes
1 answer

How to import folder-level shared libraries in jenkins pipeline

First my understanding of folder-level shared libraries: It's a groovy script I can place anywhere in the repository where I want it to use (i.e. where my Jenkinsfile will be). If this is wrong please let me know. My question: How can I include this…
Yannic Bürgmann
  • 6,301
  • 5
  • 43
  • 77
9
votes
6 answers

access environment variables in jenkins shared library code

When I use my new shared library I cannot access environment variables for any src class which is executed either directly by the Jenkinsfile or via a var/*.groovy script. This problem persists even when I add withEnv to the var/*groovy…
Peter Kahn
  • 12,364
  • 20
  • 77
  • 135
8
votes
5 answers

How to generate groovydoc from jenkins global library

I have a jenkins global library and I want to document it. I want to use groovydoc. The library contains classes and global vars src/ vars Generating documentation for the classes is no problem: groovydoc -sourcepath src -d doc…
Nathan
  • 7,099
  • 14
  • 61
  • 125
5
votes
2 answers

Jenkins Shared Library - Importing classes from the /src folder in /vars

I am trying to writing a Jenkins Shared Library for my CI process. I'd like to reference a class that is in the \src folder inside a global function defined in the \vars folder, since it would allow me to put most of the logic in classes instead of…
ModoNoob
  • 51
  • 1
  • 4
5
votes
1 answer

Constructor not called in Jenkins Shared Libraries

I am trying to develop shared libraries and has the following directory structure src/com/mycomapny MyTest.groovy vars test.groovy Jenkinsfile my Jenkinsfile calls only method available in the test.groovy with required input. which imports…
5
votes
0 answers

code coverage for Jenkins shared Groovy library with jacoco

I have a shared groovy library that provides some steps (in vars folder) for a Jenkins pipeline. For the steps I have groovy unit tests in place and want to calculate code coverage with them. I already have setup jacoco successfully and get coverage…
4
votes
1 answer

How "vars" in Jenkins Shared Libraries work?

I'm experiencing some behaviors in Jenkins Shared Libraries, and it'll be great if someone can explain this to me: First issue Let's say i have a file in the vars directory: // MultiMethod.groovy def Foo() { ... } def Bar() { ... } Now if i want…
YoavKlein
  • 2,005
  • 9
  • 38
4
votes
1 answer

Import class from shared library in Jenkinsfile

I have a shared library repo with this structure: (root) +- src | +- com | +- company | +- DeploySteps.groovy +- vars | +- MainDeploySteps.groovy This library importing to job via Jenkinsfile as follows: library…
4
votes
1 answer

Accessing plugins in jenkins shared library classes

I wanted to create a class in /src directory which can access docker and other plugin steps. So I have a class that looks like this; class someClassName implements Serializable { def env def steps def docker someclassName(env,…
Z Y .
  • 313
  • 1
  • 3
  • 6
4
votes
1 answer

how to run a complete Jenkins scripted pipeline stage from shared libraries src file

I recently started with Jenkins shared libraries in Jenkins pipeline. I created a "func.groov" class and located it under "src/org/prj/func.groovy" : package org.prj import jenkins.model. class func implements Serializable { def steps func(steps)…
1
2 3
9 10