jenkins-shared-libraries

Jenkins groovy MissingMethodException No signature of method

会有一股神秘感。 提交于 2021-02-10 06:15:23
问题 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 library @Library(shared_pipeline@branch_name) _ pipeline.getThingsDone() I tried with defining getThingsDone(...) without any arguments with string arguments with Map arguments Nothing works. So I want to get a function that accepts no parameter(s) up and running. But it

How to access to a static file in resources folder of the shared library from within a class in src directory

落爺英雄遲暮 提交于 2021-01-28 11:59:23
问题 I have the Jenkins shared library with the following structure: resources |-> config.yaml |-> projects.yaml src |_ com |_ rathath |_ jenkins |-> Configuration.groovy In src/com/rathath/jenkins/Configuration.groovy , I want to read YAML files in resources directory. I tried : @Grab('org.yaml:snakeyaml:1.17') import org.yaml.snakeyaml.Yaml import hudson.FilePath // ... def readConfig() { def config = [:] def cwd = hudson.model.Executor.currentExecutor().getCurrentWorkspace().absolutize() new

Jenkins Shared Library - Importing classes from the /src folder in /vars

我的梦境 提交于 2020-05-13 23:18:47
问题 I am trying to writing a Jenkins Shared Library for my CI process. I'd like to reference a class that is in the \src folder inside a global function defined in the \vars folder, since it would allow me to put most of the logic in classes instead of in the global functions. I am following the repository structure documented on the official Jenkins documentation: Jenkins Shared Library structure Here's a simplified example of what I have: /src/com/example/SrcClass.groovy package com.example

Jenkins Shared Library - Importing classes from the /src folder in /vars

限于喜欢 提交于 2020-05-13 23:16:23
问题 I am trying to writing a Jenkins Shared Library for my CI process. I'd like to reference a class that is in the \src folder inside a global function defined in the \vars folder, since it would allow me to put most of the logic in classes instead of in the global functions. I am following the repository structure documented on the official Jenkins documentation: Jenkins Shared Library structure Here's a simplified example of what I have: /src/com/example/SrcClass.groovy package com.example

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

偶尔善良 提交于 2019-12-23 23:12:22
问题 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') _ generic_pipeline { parameters { choice(choices: namespaces, description: 'namespaces ?', name: 'namespaceIdChoice') string(defaultValue: "$BRANCH_NAME-$BUILD_NUMBER", description: 'What is the project name ?', name: 'projectName') } } my generic_pipeline

access environment variables in jenkins shared library code

旧巷老猫 提交于 2019-12-21 05:10:52
问题 When I use my new shared library I cannot access environment variables for any src class which is executed either directly by the Jenkinsfile or via a var/*.groovy script. This problem persists even when I add withEnv to the var/*groovy script. What is the trick to get environment variables to propagate to jenkins shared library src class execution? Jenkinsfile withEnv(["FOO=BAR2"]) { println "Jenkinsfile FOO=${FOO}" library 'my-shared-jenkins-library' lib.displayEnv() Shared Library var/lib

Jenkins declarative pipeline 1.3 run parallel for all jobs

╄→尐↘猪︶ㄣ 提交于 2019-12-13 05:13:39
问题 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 jobs e.g. jobs = [job1, job2, job3] and run above pipeline code for different jobs. Something similar to https://jenkins.io/doc/book/pipeline/syntax/#script-example Can I use a for loop or similar logic to run a declarative pipeline? I found similar

Cannot instantiate an object in Jenkins Shared Library

旧巷老猫 提交于 2019-12-12 20:14:45
问题 Currently I am working on creating a Jenkins shared library in my project and facing a problem trying to instantiate an object. Tree structure of my application - day#1 -- ./Jenkinsfile -- ./src/File1.groovy -- ./test/File1Spec.groovy -- ./vars/file1.groovy From my Jenkinsfile I can call file1.function which inturn will create a class object written in the file ./src/File1.groovy and it works perfectly, But on day#2, I add one more class(src/File2.groovy) and tried to create an object in vars