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
0
votes
0 answers

How to load other library in git repo from jenkins shared library?

I'm using 2 shared libraries. (A, B) A is using the B shared library, and I am trying to write a test code, but the B library is not recognized. Both are in the github enterprise repository. Purpose import library B from workspace A to a git address…
jx2lee
  • 1
  • 1
0
votes
1 answer

Jenkins/Groovy: How to declare/use an enum outside class?

I have a Jenkinsfile that calls function setup() from shared-lib my_lib: // Jenkinsfile @Library('my_lib@dev') my_lib import groovy.json.JsonOutput pipeline { agent any stages { stage( "1" ) { steps { script { d =…
StoneThrow
  • 5,314
  • 4
  • 44
  • 86
0
votes
1 answer

Jenkins shared-library: custom step

Following this section of jenkins documentation, I’ve defined a global var in: my-shared-library/vars/unLabel.groovy The library is loaded implicitly and the code is: def call(String labelName, String tfsPath) { echo "Hello, ${labelName}…
Lety
  • 2,511
  • 21
  • 25
0
votes
1 answer

Jenkins Groovy error groovy.lang.MissingMethodException when trying to use readFile()

I've been getting an odd error in Jenkins when trying to run readFile() within a shared library, so that I can determine if a Dockerfile is pulling from ECR or docker hub. The error is :- hudson.remoting.ProxyException:…
Steve Button
  • 57
  • 2
  • 8
0
votes
1 answer

Evaluate return value from Jenkins shared library in unit test with jenkins-spock

So I have a scripted shared pipeline library in my vars folder that returns some value at the end: def call() { def a = 3 //does stuff return a } Now I try to test it like this: def "example test"() { when: def result =…
Kathi
  • 323
  • 2
  • 13
0
votes
1 answer

Closure as argument in Jenkins shared library function

let's say I have a Configuration class in a Jenkins shared library written like this class Configuration { String param1, param2 Closure closure1 } There's also a helper class like this class Helper { String helperMethod(String arg1,…
Nunuzac
  • 13
  • 3
0
votes
1 answer

Getting groovy.lang.MissingPropertyException: No such property: datepart for class: groovy.lang.Binding

I am newbie to jenkins pipeline scripting and i am just trying to concatenate date to string getting below No Such Property exception. Dont know where am doing wrong. Could some one please help me to resolve this def generateRandomText(){ def…
0
votes
2 answers

Jenkins Shared Library script on Jenkins Agent nodes

I noticed JSL scripts get executed only on Jenkins Master, is it possible to run JSL script on Jenkins Agents? I have multiple stages in my Pipeline and I wish to run those stages on different Jenkins Agent nodes. My primary motivation for using JSL…
0
votes
1 answer

Jenkins shared libraries with kotlin

I have to add some kotlin-written classes at groovy-written shared library to use it in my jenkins pipeline. However, these classes aren't available: WorkflowScript: 19: unable to resolve class package.name.KotlinClass And i don't have the same…
0
votes
1 answer

How to collect build history by using Jenkins Shared Libraries

We would like to analyze the build history in a Jenkins job. We don't want to approve any dangerous signatures, so the logic should be implemented as a step in a Jenkins Shared Library. We use folders and multibranch jobs, so the mechanism has to…
agabrys
  • 8,728
  • 3
  • 35
  • 73
0
votes
2 answers

Skip Stages in Jenkins shared library based on repository

I have a common Jenkins shared library for all the repositories as below. vars/_publish.groovy pipeline { environment { abc= credentials(’abc') def= credentials(‘def’) } stages { …
0
votes
0 answers

Jenkins shared lib cannot import Java class from src to vars script

I created shared jenkins lib with the following structure: mylib/src/com/company/config/Config.java (this class contains lambdas) mylib/vars/configClient.groovy (contains several methods with annotation @NonCPS and imports from…
Ray
  • 1,788
  • 7
  • 55
  • 92
0
votes
0 answers

using sh() vs. execute() in a Jenkins Groovy shared library design - switches between hosts?

When using a piece of test code running 'sh' vs 'execute' i noticed a great differences in environment variables. It quickly looked as if two totally different host were involved - even if lines of invocation are only some two lines away on the very…
Alexander Stohr
  • 159
  • 1
  • 18
0
votes
3 answers

How to setup Jenkins shared library with Subversion

Every example I've seen for Jenkins shared library setup on the web is based on Git/GitHub. Can anyone help me with that using Subversion? I've struggled a lot but could not figure out what should be specified as the Default version. I've tried many…
Sid
  • 145
  • 1
  • 11
0
votes
1 answer

Using another class from Jenkins Shared Pipeline

I am currently using a Jenkins library without issues from my jobs. Right now I am trying to do some refactor, there is a chunk of code to determine with AWS account to use in almost every tool we currently have in the library. I created the…
Jon Heckman
  • 420
  • 2
  • 7
  • 18