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

Passing environment variable as a pipeline parameter to Jenkins shared library

I have a shared Jenkins library that has my pipeline for Jenkinsfile. The library is structured as follows: myPipeline.groovy file def call(body) { def params= [:] body.resolveStrategy = Closure.DELEGATE_FIRST body.delegate = params …
Joe
  • 337
  • 6
  • 21
0
votes
1 answer

Possibility to disable the property syntax for accessing a getter in groovy?

Let's I have a groovy class like: class SomeClass { String myProperty = 'foo' } Usually in groovy is will be totally valid to access the value using the property name or the getter - which usually gives the same result for SomeClass: SomeClass…
Joerg S
  • 4,730
  • 3
  • 24
  • 43
0
votes
1 answer

Return String After Character in Jenkins

I'm using shared libraries in groovy. I have this variable which will return : feature/nameofthebranch def BRANCH = steps.sh(returnStdout: true, script: 'git rev-parse --abbrev-ref HEAD').trim() However I only need the character after the "/" I've…
WhoAmI
  • 1,013
  • 2
  • 9
  • 19
0
votes
1 answer

How to specify branch name for shared library as environment variable

I want to refer/specify (syntax) branch which is set as an environment variable for Jenkins shared library which will be provide during docker container. For Example: @Library(['my-shared-library', BRANCH_NAME]) Tried using ${BRANCH_NAME}…
0
votes
1 answer

jenkinspipeline groovy.lang.MissingMethodException: No signature of method

I have created a pipeline that takes an array of JSON objects and will call a shared library which will iterate over the JSON objects When trying to run the Jenkins job to test that I can forward the objects but I'm seeing the following…
0
votes
4 answers

Jenkins pipeline get "No such property" with pipeline library

In my shared libraries, I define: vars/checkoutSvnCode.groovy #!/usr/bin/env groovy //get svn code def call(String URL="url") { def scmVars = checkout([ $class: 'SubversionSCM', additionalCredentials: [], …
sam
  • 1
  • 1
0
votes
1 answer

Calling Jenkins git plugin from a shared library class

I have a long standing declarative pipeline infrastructure I would like to start putting repeated code into shared libraries The problem I am facing is calling the git plugin from a shared library function/class. I'm a bit lost as my experience is…
emmdee
  • 1,541
  • 3
  • 25
  • 46
0
votes
1 answer

Jenkins MultiBranchPipeline loads shared library repo first

I am experiencing an issue where the shared library is retrieved before the main repository is retrieved in my MBP job. This was not the case in my regular pipeline and freestyle jobs. Because a Jenkinsfile shared library method attempts to read…
0
votes
1 answer

How to use groovy constant from Shared Libray in Jenkins file (pipeline)?

I want use grrovy constant from Shared Libray in my Jenkins pipeline. I try this but I have this error: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: WorkflowScript: 27: Not a valid stage section definition: "def…
Stéphane GRILLON
  • 11,140
  • 10
  • 85
  • 154
0
votes
0 answers

Jenkins groovy code fails when called from a folder shared library

I have a groovy class which I am attempting to import from a folder-level shared library. Here is the groovy class - package abc.esmm @Singleton class JiraCommands implements Serializable { def steps def…
user1751044
  • 71
  • 1
  • 2
0
votes
1 answer

Loading a shared library implicitly

I would like to integrate a Global library into my build flow. I have written a basic function srv/core/jenkins/Checks.groovy: package core.jenkins class Checks implements Serializable { def script Checks(script) { this.script = script } def…
Jason Stanley
  • 386
  • 1
  • 3
  • 20
0
votes
0 answers

Importing packages inside a package in jenkins-shared-libraries

My jenkins-shared-libraries structure is this: vars |_mainPipeline.groovy resources src |_ com |_company |_utils.groovy |_data.groovy utils.groovy: package com.company; def getCommitHash() { return…
Moshe
  • 4,635
  • 6
  • 32
  • 57
0
votes
0 answers

Jenkins Shared Library: Function with single required String parameter

I have a shared library for a project specific Jenkins Setup. One of my files in vars/gradle.groovy looks as follows: /** * simple wrapper around the ./gradlew command in a repository. * * * @param command : the gradle command that will be…
0
votes
1 answer

Jenkins pass trigger block to Shared Library Pipeline

I have a Shared Library containing a declarative pipeline which numerous jobs are using to build with. However I want to be able to pass the trigger block in from the Jenkinsfile to the Shared Library as some jobs I want to trigger via Cron, others…
0
votes
1 answer

Jenkins PipelineShared library using Java

I know using Groovy, Jenkins Pipeline Shared library can be developed. I want to know if there is any way the same Jenkins pipeline shared library can be developed using Java or any other technology?