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
1
vote
1 answer

Calling a shared library function without parameters

I'm using a shared library with jenkins 2. Meaning, I'm utilizing the ability to reuse some of the pipeline code I'm writing in various stages. here is an example of module vars/utils.groovy def set_virtual_env() { sh """ chmod 777…
1
vote
4 answers

How to implement shared library in jenkins, without configuring "Global Pipeline Libraries" in "Manage Jenkins"?

Since I don't have access to "Manage Jenkins" menu in my organization, I'm unable to configure my shared library in "Global Pipeline Libraries" in "Manage Jenkins". Is there any other way to implement this, without configuring in Manage…
1
vote
0 answers

Jenkins shared libraries - Loading variables

My project has many common variables for many other projects, so I use Jenkins Shared Library and created a vars/buildMeta.groovy file where I defined my variables (some sh parse functions), and use them at the environment stage (var1,…
1
vote
0 answers

'Include' a shared library pipeline in other pipelines in the same shared library

I have several microservices which use the same pipeline from a shared library which is named jenkins-shared-pipelines . The Jenkinsfile for a microservice is as follows: @Library(['jenkins-shared-pipelines']) _ gradleProjectPrPipeline([buildAgent:…
1
vote
1 answer

In a Jenkins shared library infrastructure, how do I import class in another file?

I'm using Jenkins shared library plugin and have the following structure src/com/domain/service/baseClass.groovy " /subClass.groovy I have this in baseClass.groovy class BaseClass { Integer port = 5000 String name =…
Chris F
  • 14,337
  • 30
  • 94
  • 192
1
vote
0 answers

No such DSL method in Jenkins Declarative pipeline

I have the following pipeline file which is meant to be used for creating an instance in the openstack. @Library('dev-shared-lib@master')_ pipeline{ agent any stages{ stage('Create OpenStack Instace'){ environment{ …
1
vote
1 answer

Jenkins shared library: How to run code from a python module contained in a package?

I want to run a python script as part of a jenkins pipline triggered from a github repo. If I store the script directly in the repo itself, I can just do sh 'python path/to/my_package/script.py' which work perfectly. However since I want to use this…
1
vote
1 answer

How to pass variable name, but not its value into /var function as argument piece?

I'm trying to divide a pipeline. Most of the parameters passed successful, but those containing variables are resolved before i need. Jenkins ver. 2.164.1 Jenkins.file content: stage ('prebuild') { steps { script { VERSION="temprorary-value" …
gek
  • 524
  • 6
  • 18
1
vote
1 answer

Problem using Kaniko to build containers from a Kubernetes CloudBees Jenkins shared-library

I am trying to build containers using a Jenkins shared-library that calls Kaniko. Jenkins is CloudBees Core running on a Kubernetes cluster. I prefer to try to use pod templates to build containers, but I can fall back to a dedicated VM if I have to…
tdensmore
  • 667
  • 1
  • 6
  • 19
1
vote
0 answers

Can I use jenkins post step from inside a shared library?

In a shared library method I'm trying to execute a stage and a post step afterwards: def call(String name = 'human') { echo "Hello, ${name}." this.stage("mystage"){ this.node('master') { this.sh('echo executing stage') } } …
1
vote
1 answer

groovy.lang.MissingMethodException With PowerMock and Jenkins getItemByFullName

How can I use PowerMockito to ensure Jenkins static method returns my mocked object? I see that if I have a test, that Jenkins is the mock. However, if I add what looks like a valid PowerMockito.when for an additional static method, I get the error…
Peter Kahn
  • 12,364
  • 20
  • 77
  • 135
1
vote
2 answers

How can I define additional parameters in a declarative jenkins pipeline who inherit from a pipeline shared library?

I'm looking to see if it's possible for something like this: How can I define additional parameters in jenkinsfile who inherit from a pipeline shared lib? But in a declarative pipeline, I've tried solutions similar to that of the post above but with…
1
vote
1 answer

How to pass arbitrary number of arguments to Jenkins shared library

I got this shared library vars/libOne that takes composeFileNames parameter as a list of strings. #!/usr/bin/env groov def call(String param1, String param2, String parm3, String[] composeFileNames ) { String s ='' for (int i…
1
vote
1 answer

Any strategies for locking down Jenkins credentials to a shared-library?

I like the use of Jenkinsfiles and shared-libraries for their purported benefits, but i have some governance concerns about execution of arbitrary Jenkinsfiles (and potential use of broadly scoped credentials). I'm thinking it would be convenient…
tony_k
  • 1,983
  • 2
  • 20
  • 27
1
vote
0 answers

Triggering Pipeline in loop with different parameter in sequence

I read about sharing standard pipeline for multiple projects here I have a use case where i want to run pipeline template by multiple data in a loop.This pipeline should run sequentially. Here is the code : //Jenkinsfile startPipeline() def…