jenkins-shared-libraries

Jenkins Pipeline - Call functions in shared jar

别说谁变了你拦得住时间么 提交于 2019-12-08 15:15:23
问题 So here is my project setup A separate groovy project Multiple pipelines All the pipeline scripts refer to the shared groovy project. I went through the shared libraries and all of the needs to be registered in Jenkins global configuration. Is there any way to do without it? I tried using Grab but ended up with the error java.lang.RuntimeException: No suitable ClassLoader found for grab 回答1: Firstly for Grab to work your Jenkins needs to have access to the internet. Shared Libraries are

Is there a way to move the entire post {} build section in Jenkinsfile to the global pipeline library?

蹲街弑〆低调 提交于 2019-12-07 14:44:03
问题 I'm relatively new to Jenkins pipelines, but having implemented already a few, I've realised I need to start using jenkins shared library before I go mad. Have already figured out how to define some repetitive steps in the library and call them with less clutter from Jenkinsfile, but not sure if the same thing can be done for the entire post build section (thought I've read about to how to define the entire pipeline in the lib and similar), as this is pretty much static end of every single

Is there a way to move the entire post {} build section in Jenkinsfile to the global pipeline library?

天大地大妈咪最大 提交于 2019-12-06 01:36:53
I'm relatively new to Jenkins pipelines, but having implemented already a few, I've realised I need to start using jenkins shared library before I go mad. Have already figured out how to define some repetitive steps in the library and call them with less clutter from Jenkinsfile, but not sure if the same thing can be done for the entire post build section (thought I've read about to how to define the entire pipeline in the lib and similar ), as this is pretty much static end of every single pipeline code: @Library('jenkins-shared-library')_ pipeline { agent none stages { stage ('System Info')

access environment variables in jenkins shared library code

◇◆丶佛笑我妖孽 提交于 2019-12-03 15:27:39
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.groovy def displayEnv() { println "Shared lib var/lib FOO=${FOO}" MyClass c = new MyClass() } Shared