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

Can I have an entire declarative pipeline defined and parameterized in a shared library?

Essentially I want my Jenkinsfile to look something like this: @Library('my-descriptive-pipline') _ myPipeline('arg1','arg2','arg3') Then my shared library (/vars/descriptivePipeline.groovy) would look like this: pipeline { agent any …
red888
  • 27,709
  • 55
  • 204
  • 392
3
votes
1 answer

String interpolation in a shared library's global variable

Cloudbees 2.289.1.2 I am changing the code as per the Jenkinsfile string interpolation guidelines. Note: I am aware that Groovy String interpolation expects double-quotes for variables to be included. There are several sh in several global…
3
votes
2 answers

Trying to trigger all jobs parallel using shared library

I wanted to trigger all jobs in a jenkins folder from another job, for this i tried writing jenkins shared library and used it. However it triggers the builds and then it fails with exception My shared library runAllJobsInFolder.groovy: def…
3
votes
1 answer

Is there a way to move the entire post {} build section in Jenkinsfile to the global pipeline library?

I'm relatively new to Jenkins pipelines, but having implemented already a few, I've realised I need to start using jenkins shared library before I go mad. Have already figured out how to define some repetitive steps in the library and call them with…
3
votes
2 answers

library variable in jenkins shared library

I have a Jenkins shared lib in a repo, usual folder structure: vars utils.groovy In utils.groovy I have some functions: void funcA() {} void funcB() {} Now I want to define a constant that all functions in that module can use, but when I try…
Oliver
  • 27,510
  • 9
  • 72
  • 103
3
votes
2 answers

Jenkins groovy MissingMethodException No signature of method

I am facing getThingsDone() is applicable for argument types: () values: [] error for code as below, in shared library .... vars/pipeline.groovy def getThingsDone(m = null){ echo "done" } in some project that includes shared…
Aditya shops
  • 95
  • 1
  • 1
  • 6
3
votes
1 answer

How can I define additional parameters in jenkinsfile who inherit from a pipeline shared lib?

I would like to add a possibility to extends the global parameters define in a Jenkins pipeline. Each JenkinsFile who call the default pipeline have default parameters and he as able to define parameters himself like this: @Library('mylib') _…
3
votes
0 answers

Refactor jenkins post block in a shared library

I'm desperately trying to refactor a post block for all my pipelines. I'd like to push a slack notification after every pipeline execution. The code for one pipeline looks like this: @Library('prixan-shared-library') import…
3
votes
1 answer

how to call a Jenkins 2 shared library with parameters and a closure from a Jenkinsfile pipeline?

I would like to call the next shared library from a pipeline: [a link] https://github.com/docker/jenkins-pipeline-scripts/blob/master/vars/wrappedNode.groovy I don't know how to call and populate the vars map and the body closure from the Jenkins 2…
3
votes
1 answer

Creating custom steps in groovy

I'm working with jenkins pipeline and have a shared global library. I created several functions that users can use, however the main problem I'm facing is having better output in the Console Output and Blue Ocean: Is there a way to create in groovy…
2
votes
1 answer

How to mock variables from a groovy file

I have a groovy file created under "vars" in a Jenkins-shared-lib. Few variables are defined inside call(). I want to mock the variables in a groovy test file. Variables are defined in sonarGradleProject.groovy in vars: #!/usr/bin/env groovy import…
2
votes
1 answer

groovy.lang.MissingMethodException: No signature of method: httpRequest() is applicable for argument types: (java.util.LinkedHashMap)

I have the following piece of code that used to work great in a pipeline. I have to move it into a shared library in Jenkins, so created a class for it and made the necessary adjustments. def toJson (input) { return…
2
votes
1 answer

Executing shell commands from inside Pipeline Shared Library

I'm writing a shared library that will get used in Pipelines. class Deployer implements Serializable { def steps Deployer(steps) { this.steps = steps } def deploy(env) { // convert environment from steps to list …
Sagar
  • 9,456
  • 6
  • 54
  • 96
2
votes
0 answers

Jenkins/Groovy: why are functions forbidden by scripts permitted by imported libraries?

Question: why are some functions disallowed if called in a Jenkinsfile, but allowed if called in a shared library that is imported by that same Jenkinsfile? This question is not specific to directory-creation, but I will use it as an example, since…
2
votes
0 answers

Jenkins/Groovy: how to call readJSON from shared library class constructor?

How can I define a class in a Jenkins shared library that contains an empty JSON object? // src/org/build/Report.groovy package org.build public class Report implements Serializable { def steps def json Report(steps) { this.steps =…
StoneThrow
  • 5,314
  • 4
  • 44
  • 86
1
2
3
9 10