基于分支加载动态全局库

时间:2019-05-31 15:43:44

标签: jenkins-pipeline

我正在尝试基于分支加载全局共享库。拉:

@Library ("pipelines@$BRANCH_NAME")

我可以静态地做到这一点:

@Library ("pipelines@the_branch_i_want") _

但不是

@Library ("pipelines@$BRANCH_NAME")

也不

@Library ("pipelines@$env.BRANCH_NAME")

也不

library "pipelines@the_branch_i_want"

也不

properties([parameters([string(name:'BRANCH_NAME', defaultValue: "${env.BRANCH_NAME}")])])
library "pipelines@${parameters.BRANCH_NAME}"

在Jenkins全局配置中 隐式加载:未选中 允许覆盖默认版本:选中 在作业的最近更改中包括@Library更改:已选中

@Library ("pipelines@the_branch_i_want") _
import com.mycompany.jenkins.pipelines.*

APP_NAME = "our_app"
BRANCH_NAME = env.BRANCH_NAME 

MyCompanyPipeline pipeline = new MyCompanyPipeline()

//I don't need to pass the branch name, but I can see that env.BRANCH_NAME is set to what I need.
pipeline.myCompanyPipeline(APP_NAME, BRANCH_NAME)

所有库指令均导致: WorkflowScript:10:无法解析类MyCompanyPipeline

@Library指令错误有所不同。主要是“您是要使用'图书馆'吗?”

0 个答案:

没有答案