Jenkins Pipelines: Why is CPS Global Lib not loading?

后端 未结 2 701
我寻月下人不归
我寻月下人不归 2021-01-23 09:32

I\'m following the tutorial on the pipeline library plugin. I made a repository containing the following files:

D:.
│   Test.groovy
│   
├───src
└───vars
                


        
相关标签:
2条回答
  • 2021-01-23 10:09

    Using the 2.8 version of Pipeline:Groovy plugin I found that if I update the groovy scripts under /vars/myscript.groovy doesn't work, but if I restart jenkins everything works fine. If I simply reload configuration from file, nothing happens.

    So I think the scripts are instantiated as global functions only when jenkins start. (but maybe I'm wrong :) )

    0 讨论(0)
  • 2021-01-23 10:10

    The Pipeline Global Library expects a Git push event to update the Jenkins embedded workflow-libs git repo.

    A push triggers the UserDefinedGlobalVariableList.rebuild() method see: https://github.com/jenkinsci/workflow-cps-global-lib-plugin/blob/master/src/main/java/org/jenkinsci/plugins/workflow/cps/global/UserDefinedGlobalVariableList.java

    Here is a groovy script that pulls a GitHub repo into the Jenkins workflow-libs repos and then reloads it without a restart via:

    //Get Pipeline Global Library Jenkins Extension that rebuilds global library on Git Push List extensions = ExtensionList.lookup(UserDefinedGlobalVariableList.class); extensions.get(0).rebuild() //may want to add a check here to make sure extensions isn't null

    0 讨论(0)
提交回复
热议问题