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
2
votes
1 answer

How to define credentials and environment variables in jenkins shared library

Currently I am having the following code in my Jenkins file environment { GITHUB_USER = credentials('GITHUB_USER') GITHUB_TOKEN= credentials('GITHUB_TOKEN') DOCKER_USER = credentials('DOCKER_USER') …
2
votes
1 answer

Feeding parameters to Jenkins shared library

I have a Jenkins shared library that I use for my Jenkinsfile. My library has an entire pipeline and it has a function (lets call it examFun()) that is used within my pipeline. My Jenkinsfile: @Library('some-shared-lib') _ jenkinsPipeline{ …
Joe
  • 337
  • 6
  • 21
2
votes
2 answers

How to access to a static file in resources folder of the shared library from within a class in src directory

I have the Jenkins shared library with the following structure: resources |-> config.yaml |-> projects.yaml src |_ com |_ rathath |_ jenkins |-> Configuration.groovy In…
Abdennour TOUMI
  • 87,526
  • 38
  • 249
  • 254
2
votes
1 answer

Is there a way to track usage of a global shared library in Jenkins?

Context: At my work most developers are free to write their own Jenkinsfile for their own team's projects. As the Jenkins admin, I provide developers with a global shared library. Most projects are using either v1 or v2 or v3 or another version of…
2
votes
0 answers

Including multiple steps as external file in pipeline

I'm trying to split my pipeline to multiple files, So one stage has multiple stages inside it, I want to move it to a different file inside vars directory in jenkins-shared-library I'm importing. #!/usr/bin/env groovy @Library('utils-library')…
2
votes
0 answers

how to avoid Jenkins asking for in-process approval for call in trusted shared pipeline

TLDR; How to configure jenkins in a non-interactive way so people can use my shared library without me needing to go click on the approve button for the in-process script. long story... I have created a shared Library in Jenkins which looks…
Chris Maes
  • 35,025
  • 12
  • 111
  • 136
2
votes
1 answer

IntelliJ GSDL: Define method with optional arguments

I have Jenkins pipeline shared library, that specifies a global variable foo which provides two methods. One of the has no argument, the other has one optional argument: /vars/foo.groovy def getBarOne() { //... } def getBarTwo(String value =…
2
votes
0 answers

how to import external class in Jenkins shared library

Im trying to import a not shared library class to a shared library class and gets an error: file structure . ├── src │   └── org │   └── jenkins │ └──shared_library.groovy │ └──not_shared_library.groovy │ │──…
2
votes
1 answer

Jenkins library step fails if not wrapped in script

I'm having a strange issue which I can't seem to quite understand. I have written a custom step which accepts parameters used to clone github/bitbucket repositories more easily. The step works just fine - it calls the appropriate checkout() for…
tftd
  • 16,203
  • 11
  • 62
  • 106
2
votes
0 answers

Type 'com/fasterxml/jackson/dataformat/yaml/YAMLFactory' (current frame, stack[0]) is not assignable to 'com/fasterxml/jackson/core/JsonFactory'

I get this error when using swagger parser inside a jenkins shared library pipeline Groovy Grapes Grab: @Grab('io.swagger:swagger-parser:2.0.0-rc1') @Grab(group='com.fasterxml.jackson.core', module='jackson-databind',…
2
votes
1 answer

Cannot instantiate an object in Jenkins Shared Library

Currently I am working on creating a Jenkins shared library in my project and facing a problem trying to instantiate an object. Tree structure of my application - day#1 -- ./Jenkinsfile -- ./src/File1.groovy -- ./test/File1Spec.groovy --…
1
vote
0 answers

What is the rationale behind Jenkins's `load` vs. `library` functions?

This question follows from How can I dynamically load shared libraries in a Jenkinsfile and execute their same-named global variable methods? Why does load return an object that scopes the loaded Groovy script's global variable methods whereas…
1
vote
0 answers

Jenkins shared library unit tests - missing dependencies and assert singleton values

I'm trying to write unit test to my Jenkins shared library using jenkins-pipeline-unit but for no success. My project/directory structure is: src/ └── org └── company ├── JobData.groovy ├── Constants.groovy ├──…
1
vote
0 answers

Can a Groovy source file in Jenkins' Shared Library access a method from a global variable?

Can a Groovy source file in Jenkins' Shared Library access a method from a global variable? my Shared Library structure is: (root) +- src # Groovy source files | +- org | +- foo | +- CallMethodFromVars.groovy #…
Marcin Kulik
  • 845
  • 1
  • 12
  • 28
1
vote
0 answers

Custom Exception class Jenkins Groovy

I created a custom exception class and put it inside src/org/team/pipeline/TestResultFailed.groovy: package org.team.pipeline public class TestResultFailed extends Exception { // Parameterless Constructor public TestResultFailed() {} //…
1 2
3
9 10