是否可以使用DSL groovy脚本在“使用全局Veracode用户凭据”复选框中打勾?

时间:2019-04-18 12:21:39

标签: jenkins-plugins global dsl veracode

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

它可以很好地与我拥有的代码配合使用,并添加了复选框,但没有为我检查它,而是在寻找凭据。我想使用全局凭证。我已将其添加到发布者块下。如您在我的代码中看到的那样,在“凭据”部分下,我将凭据留空,因为我不想指定任何一个。单击“使用全局Veracode用户凭据”复选框,省略这些参数,并使用在manage 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("")
                }

            }
        }

1 个答案:

答案 0 :(得分:0)

我无法从Veracode上找到任何文档,因此我最终不得不对插件进行反编译才能弄清楚。这可以通过将凭据对象设置为空值来实现。

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

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