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

Cannot import package in unit tests for a Jenkins Shared Library

I'm attempting to create unit tests for a JenkinsShared library using Gradle in order to run the test tasks. I've followed this tutorial which upon conclusion one has a working test suite for a shared library for functions within the vars folder…
1
vote
1 answer

Jenkins shared library - create a generic function for the options section

I want to expand our shared library usage - want to add a function that will contain all the options for the pipeline: options { disableConcurrentBuilds() timestamps() timeout(time: 30, unit: 'MINUTES') …
Mor Lajb
  • 2,546
  • 1
  • 15
  • 28
1
vote
2 answers

how to run vars/script.groovy from a Jenkins shared library

I'm trying to get information from a groovy script located under vars called from a shared library Jenkins class but gets an error. some info: Need - global configuration file. similar to Manage Jenkins -> Configure System -> Environment…
user1789357
  • 93
  • 2
  • 10
1
vote
1 answer

Using a shared library class from a custom step with Jenkins pipeline shared libraries

I am setting up a shared library for Jenkins pipelines and am trying to figure out how to import a class in the shared library into a custom step that I am writing. Here's what the directory structure looks…
1
vote
1 answer

Why is Jenkins running a shared pipeline library inside the sandbox?

I've created a git repo with the following file located at src/com/me: package com.me import com.cloudbees.groovy.cps.NonCPS class JobTriggerInfo implements Serializable { def script JobTriggerInfo(script) { this.script =…
1
vote
1 answer

jenkins use other variables in my own shared library

I'm writing my own shared library. Now I want to use global variable in my code. How can I make that happen ? I.E. I write a class. class MyWork { build() { // here I want to use global docker(which is docker-plugin) …
xren
  • 1,381
  • 5
  • 14
  • 29
1
vote
1 answer

Log4j2 write to Jenkins pipeline job console output?

How can I use log4j2 to log messages into a Jenkins pipeline job console output (while the job is running)? By console output, I mean the log of text outputted from a job typically found: http://localhost:8080/job//
Daniel
  • 8,655
  • 5
  • 60
  • 87
0
votes
1 answer

How can I dynamically load shared libraries in a Jenkinsfile and execute their same-named global variable methods?

I want to load variably-named shared libraries in my Jenkinsfiles sequentially, and run a global variable method of the same name in each one. I.e. as pseudocode, what I want to do is: for lib in in [foo, bar]: load shared library(lib) run the…
0
votes
0 answers

How to configure the branch of the jenkins @Library( 'pipeline@branch') _ programmatically

Context: MultiBranchPipeline Shred Library We are working on test automation for pipeline development in our CI/CD system. Our CI/CD system triggers builds based on commits to a bitbucket repositories having a Jenkinsfile (MultiBranch pipeline) for…
0
votes
0 answers

Is there some way to pull in Jenkins plugins from a shared pipeline library?

Jenkins publishes plugins which contains primarily, or only, additional pipeline steps. For example, pipeline-utility-steps would be nice to have, because it has the tar task. But getting additional plugins installed in the Jenkins instance comes…
Hakanai
  • 12,010
  • 10
  • 62
  • 132
0
votes
1 answer

Unable to return a declaratively defined stage from closure to jenkins shared library

I have been working on creating a jenkins shared library, and it works perfectly for a generalized pipeline template. Recently I had the need to pass an extra user-defined stage to my generalized pipeline. I am using closure to do so, but facing…
0
votes
1 answer

Job DSL plugin | Shared Library | Pipeline jobs | Github Hook not working

Please bear with me the description might be long but it might give a clean picture of the intent and issue. I have used Job DSL Plugin to create a seeder job, which in turns creates two new Jobs. I have 2 separate repositories For maintaining…
0
votes
1 answer

How can I create scoped environment variables in my Jenkinsfile?

The Jenkins credentials plugin provides a withCredentials function that can store the value of a credential into a scoped environment variable as seen here. node { withCredentials([usernameColonPassword(credentialsId: 'mylogin', variable:…
0
votes
0 answers

How to add parameters to jenkinsfile based on condition

I have a requirement as below i will configure 2 different jobs with different parameters. i am using pipeline shared libraries and under vars folder, my deriveJobParams.groovy looks as follows. def call(Map config = [:]) { properties([ …
0
votes
0 answers

Pass parameters to Jenkins shared library

I just simply want to pass the repo name cloud-nates in shared pipeline, so i've passed the parameter deployName from jenkinsfile to shared library. below is the Jenkinsfile @Library("minePipelines@auto") _ if (env.BRANCH_NAME in ["auto",…