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

How to define pipeline stage once and using it multiple times

So I have a use case with Jenkinsfile that I know is not common, and I haven't found a solution for it yet. Background We currently have a multi-branch pipeline job configured to build multiple branches. This is uses to run system-testing of the…
bkhouri
  • 243
  • 6
  • 14
0
votes
3 answers

Trigger Jenkins Job from shared library

This is what I have in my shared library file build job: 'Job Name', parameters: [ string(name: 'ENVIRONMENT', value: 'sit'), string(name: 'param1', value: 'value1' ) ] It is failing with…
Avadh
  • 51
  • 1
  • 3
  • 10
0
votes
1 answer

Jenkins Shared Library return executable docker command

Is it possible to get a shared library to retune a docker run command? I have the following, scr/docker_run.groovy def ubuntu() { echo "docker run --rm " + '--env APP_PATH="`pwd`" ' + '--env RELEASE=true ' + "-v…
user3292394
  • 609
  • 2
  • 11
  • 24
0
votes
2 answers

Problem using external jar in Jenkins Shared Library

We are using a Jenkins Shared Library to centralize some code for all our (scripted) pipelines. Now we factored out some Groovy code into a .jar library (written in Kotlin, compiled to be Java 8 compatible). We published this library to our in-house…
0
votes
1 answer

Can we use a single jenkins file for multibranch piepeline in jenkins using shared libraries?

I am trying to write a jenkinsfile which will take the data from shared libraries in jenkins for multibranch pipeline, something like below:- @Library('Template')_ if (env.BRANCH_NAME == 'master') { jenkins1(PROJECTNAME: 'test', GITURL:…
user_9090
  • 1,884
  • 11
  • 28
0
votes
0 answers

Jenkins declarative pipeline 1.3 run parallel for all jobs

I have setup a pipeline project similar to https://jenkins.io/doc/book/pipeline/syntax/#parallel-stages-example and it works fine. But I have created the same project for different jobs, so rather than creating new jobs can I run for loop for all…
0
votes
1 answer

Jenkins Shared Library resource not found

I have just started looking into a shared libarary with jenkins in order to combine a load of scripts and pipelines across multiple repos that are pretty much identical. I have the shared lib loaded and working but when tryign to execute the…
0
votes
0 answers

Trigger once a specific downstream job

I have a pipeline that builds one or multiple downstream jobs, but I just want that only build once the downstream job. The main reason is that some jobs are triggered based on multiple conditions, and if one of the conditions match, I'll trigger…
0
votes
1 answer

Unable to resolve class inside static method

I have a groovy class "Utils.groovy" which contains the method "makeHttpCall()". This is a summarized version of the method: static String makeHTTPCall() { ... request.setHeader(javax.ws.rs.core.HttpHeaders.AUTHORIZATION, authHeader) …
0
votes
0 answers

Jenkins pipeline: load properties from file

Below pipeline codes works well: pipeline { agent { label "test_agent" } stages { stage("test") { steps { script { sh "echo 'number=${BUILD_NUMBER}' >log" …
Phoenix
  • 95
  • 3
  • 10
0
votes
1 answer

How to get a value returned from a method in a shared library in declarative syntax?

I'm using pipeline declarative syntax and I need to get a value returned from a method in a shared library pipeline{ String label= new Define.getLabel() agent (label ${label}) // stages, options ... }
0
votes
1 answer

Can i create a shared library .groovy script for a method in scripted pipeline into declarative

I am trying to convert all of the scripted pipelines at my workplace into declarative pipeline. I am new to this. I have a scripted pipeline that has 2 methods. I was able to finish the rest of the scripted to declarative but got stuck on methods.…
0
votes
1 answer

Load env variables successfully in Jenkins pipeline but not while the pipeline was used as shared library

In one stage of my declarative jenkins pipeline codes, it executes a bash script(sh '''./a.sh''', script "a.sh" is maintained outsides) - in that script, the value of "jarVersion" is injected in ${WORKSPACE}/.jarVersion (echo…
0
votes
1 answer

Jenkins pipeline: read values from another jenkinsfile

I use a shared jenkins library and clone another git repo from there. That repo contains a jenkinsfile similar to the follwing: #!/usr/bin/env groovy @Library('mylib') import jLib.* someStage{ myparam = someValue } I want to read…
herm
  • 14,613
  • 7
  • 41
  • 62
-1
votes
1 answer

Jenkins function of shared library executed on wrong node

I have a simple shared library and want to call a function which creates a file. My pipeline script looks like this: @Library('jenkins-shared-library')_ pipeline { agent { node { label 'node1' } } stages…
1 2 3
9
10