Jenkins插件开发,使用一个全局配置两个构建器



我正在开发的插件中有两个构建器,我希望它们共享相同的全局配置。我目前有一个可重复的服务器详细信息列表,我目前可以选择哪台服务器我想从下拉在builderA的配置中使用。我想为builderB的配置做同样的事情,但这需要我从builderA和用户填写两组全局配置复制全局配置。

我是否可以访问builderA的全局配置?或者将builderA的全局配置设置为全局....

我发现这个:两个不同的jenkins构建器可以存在于同一个hpi中并共享相同的全局配置吗?并复制它,以测试,但它没有告诉你如何在MyBuildStepAClass的执行方法中获得globalField1。

你可以这样做。我用selenium axis插件做到了这一点,我需要在相关类中保存selenium服务器的名称

在groovy中,但很容易转换。

//so we need this to get at the name of the selenium server in the global config
protected static Descriptor<? extends ComplexAxisDescriptor> getTopLevelDescriptor(){
    SeleniumAxis.DescriptorImpl sad = Jenkins.getInstance().getDescriptor(SeleniumAxis.class)
    sad.load()
    return sad
}

来源

我认为你需要改变

<? extends ComplexAxisDescriptor>

<? extends Descriptor>

和使用描述符为您的类,否则您的方法将无法访问

最新更新