我试图用Jenkins编写我的第一个“Groovy脚本”,并使用SVN
我的要求是使用groovy从另一个“Jenkins作业”创建一个“免费样式作业”。
使用下面的代码,我可以通过“groovy”创建一个“免费样式作业”
import jenkins.model.Jenkins;
import hudson.model.FreeStyleProject;
import hudson.tasks.Shell;
import hudson.triggers.*;
def feature_branch = build.buildVariableResolver.resolve("FEATURE_BRANCH")
job = Jenkins.instance.createProject(FreeStyleProject, feature_branch)
job.buildersList.add(new Shell('echo hello world'))
job.scm = new hudson.scm.SubversionSCM("http://base/branches/mybranche")
job.save()尽管在默认情况下该作业是创建的,但在“新创建的作业”中,“SCM凭据”设置为“无”。
1)如何使用“全局凭据”中的groovy设置“默认凭据”?2)如何通过groovy添加“构建参数”?同样,谷歌的信息也不多。
发布于 2018-07-06 10:49:28
搜索了一段时间之后,我发现以下内容使我能够设置作业的“默认凭据”
job.scm.locations[0].credentialsId = "Hash-value-of-credential"https://stackoverflow.com/questions/50962649
复制相似问题