如何解决使用Process DSL插件groovy脚本创建一个新的Jenkins作业
我需要通过复制现有maven项目中的配置来创建Jenkins新工作。 我想通过常规脚本并使用“我具有Process DSL”插件来执行此操作。我编写了下面的脚本,该脚本能够创建新工作,但是我遇到了GIT SSH URL问题
String gitRepository = 'ssh://git@stash.abc.com:1111/cegp/abc-automation-test'
String buildBranch = 'develop'
String projectName = 'APMSmokeTesting'
String credentialIDGithub = '61668d1b-3336-4c4d-90d7-721017049e36'
// job definition
mavenJob(projectName) {
logRotator {
numToKeep(20)
}
wrappers {
preBuildCleanup()
}
description('Build the Java project: ' + gitRepository)
scm {
git {
branch(buildBranch)
remote {
github (gitRepository)
credentials(credentialIDGithub)
}
}
}
triggers {
scm('@daily')
}
wrappers {
goals('clean verify -Dtags="APMSmokeTesting"')
}
}
根据上述配置,在新作业源代码管理中,存储库URL 应为ssh://git@stash.abc.com:1111 / cegp /abc-automation-test.git,因为我只需要执行SSH。 但是,上面的脚本是填充为 {3}}的填充存储库URL 。 您能帮我解决这个问题吗?
解决方法
Working code to automate job creation in Jenkins:
String gitRepository = 'ssh://git@stash.abc.com:<port>/cegp/gsc-automation-test'
String buildBranch = 'develop'
String projectName = 'APMSmokeTesting'
String credentialIDGithub = '61668d1b-3336-4c4d-90d7-721017049e36'
// job definition
mavenJob(projectName) {
logRotator {
numToKeep(20)
}
wrappers {
preBuildCleanup()
}
description('Build the Java project: ' + gitRepository)
scm {
git {
branch(buildBranch)
remote {
url (gitRepository)
credentials(credentialIDGithub)
}
}
}
triggers {
scm('@daily')
}
wrappers {
goals('clean verify -Dtags="APMSmokeTesting"')
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。