java - jelly.config 中的可选 block 不会转换到 jenkins 插件开发中的后端。

标签 java jenkins jenkins-plugins maven-jetty-plugin jelly

我的 jelly.config 包含以下内容:

        <f:block>
            <f:optionalBlock inline="true" name="dynamic" title="Mandatory parameter for rpm artifacts only" checked="false"
                help="/plugin/artifactory/help/common/help-artifactType.html">
                        <f:entry title="Operating System">
                                <select class="setting-input" name="operatingSystem">
                                        <option value="rhel5">rhel5</option>
                                        <option value="linux">linux</option>
                                </select>
                        </f:entry>
                        <f:entry title="Architecture">
                                <select class="setting-input" name="architecture">
                                        <option value="64">64</option>
                                        <option value="32">32</option>
                                </select>
                        </f:entry>
            </f:optionalBlock>
        </f:block>

在我的 serverDetails.js 中,我有:

    public class ServerDetails {
    public final String operatingSystem;
        /**
         * This the type of operating system that your rpm builds on. If not specified, this passes null. 
         */
        public final String architecture;
        /**
         * This the type of architecture your rpm runs on. If not specified, this passes null. 
         */
    }

    public ServerDetails(String artifactoryName, String artifactoryUrl, String repositoryKey, String snapshotsRepositoryKey,
                             String downloadReleaseRepositoryKey, String downloadSnapshotRepositoryKey,
                             String downloadReleaseRepositoryDisplayName, String downloadSnapshotRepositoryDisplayName,
                             String userPluginKey, String userPluginParams,String artifactKey,String productKey, String operatingSystem, String architecture, String buildType) {
            this.operatingSystem = operatingSystem;
            this.architecture = architecture;
            this.buildType = buildType;
            createStagingPlugin();
        }

public ServerDetails(String artifactoryName, String artifactoryUrl, String repositoryKey, String snapshotsRepositoryKey,
                         String downloadReleaseRepositoryKey, String downloadSnapshotRepositoryKey,
                         String downloadReleaseRepositoryDisplayName, String downloadSnapshotRepositoryDisplayName) {
        this(artifactoryName, artifactoryUrl, repositoryKey, snapshotsRepositoryKey, downloadReleaseRepositoryKey,
                downloadSnapshotRepositoryKey, downloadReleaseRepositoryDisplayName, downloadSnapshotRepositoryDisplayName, null, null,null,null, null, null, null);
    }

在我的后端 java 中,我将其用作:

public String getOperatingSystem() {
        return details != null ? details.operatingSystem : null;
    }

    public String getArchitecture() {
        return details != null ? details.architecture : null;
    }

现在,当我在前面选择操作系统和体系结构后访问它们时,当我打印出来时,我仍然得到它们的空值。

我在这里遗漏了什么吗?为什么我没有得到值(value)观。

最佳答案

在您创建的作业中,XML 有什么内容?您可以从 URL localhost:8080/job//config.xml 获取此信息

我猜您需要一个 doFillOperatingSystemItems 调用,例如 here

未经测试

public ListBoxModel doFillOperatingSystemItems(
    @QueryParameter String operatingSystem
) {
    return new ListBoxModel(
        new Option("rhel", "rhel", operatingSystem.matches("rhel") ),
        new Option("linux", "linux", operatingSystem.matches("linux") ) 
    );
}

关于java - jelly.config 中的可选 block 不会转换到 jenkins 插件开发中的后端。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28859457/

相关文章:

java - 并发java

git - 基于主干的开发有多少流水线?

continuous-integration - jenkins 开始丢失所有工作,尝试使用 'copy existing job' 功能

groovy - 带有 groovy postbuild 的 Jenkins 。无法在 groovy 脚本字段中执行任何操作

jenkins - 如何更改 Jenkins 的时区?

java - 从 IntelliJ IDEA 在 Maven 项目中添加 persistence.xml 文件

java - Spring WebServiceTemplate 的 marshalSendAndReceive 方法在发送 Request 时将 SOAP header 发送为 null

javascript - Jenkins sonarqube 插件无法分析文件

java - 如何单元测试文件访问(Java)?

java - 如何在基于 alpine 的 docker 容器上安装多个 openjdk 版本