首页 > 解决方案 > 有没有办法使用 DSL groovy 脚本勾选“使用全局 Veracode 用户凭据”复选框?

问题描述

我正在使用 DSL Groovy 脚本创建 Jenkins 作业以添加 Veracode 插件。我正在寻找一种方法来勾选“使用全局 Veracode 用户凭据”复选框。

它适用于我拥有的代码并添加了复选框,但没有为我检查它并正在寻找凭据。我想使用全局凭据。我已将其添加到发布者块下。正如您在我的代码中看到的那样,在凭据部分下,我将凭据留空,因为我不想指定其中任何一个。单击“使用全局 Veracode 用户凭据”复选框,省略这些参数并使用管理 jenkins 下指定的全局参数。

我的问题是如何使用脚本勾选此复选框。

    publishers {
            //extendedEmail Utilities.getExtendedEmail("Scan_Services", false, false)
            extendedEmail Utilities.getExtendedEmailRequester("Scan_Services", false, false)

            veracodeNotifier {
                // Enter the name of the application.
                appname("xDistributor")
                // Enter the business criticality for the application.
                criticality("Very High")
                // Enter a name for the static scan you want to submit to the Veracode Platform for this application.
                version("$BUILD_TIMESTAMP" + " Services_Scan")
                // Enter the filepaths of the files to upload for scanning, represented as a comma-separated list of    ant-style include patterns relative to the job's workspace root directory.
                uploadincludespattern("**/Services/webapps/services.war")
                createprofile(false)
                sandboxname("")
                createsandbox(false)
                filenamepattern("")
                replacementpattern("")
                uploadexcludespattern("")
                scanincludespattern("")
                scanexcludespattern("")
                waitForScan(false)
                timeout("")
                credentials {
                    vapicredential("")
                    vuser("")
                    vpassword("")
                }

            }
        }

标签: jenkins-pluginsglobaldslveracode

解决方案


我无法从 Veracode 找到任何关于此的文档,所以我最终不得不反编译插件来解决这个问题。这可以通过将凭证对象设置为空值来实现。

job('job-name') {
    publishers {
        veracodeNotifier {
            credentials(null)
        }
    }
}

其工作方式是 Veracode 插件的配置设置不检查字段的值,而是检查凭证对象是否为空,以及是否设置了全局凭证。


推荐阅读