![](/img/trans.png)
[英]Add 'execute python script' as build step while creating a jenkins job using groovy with job dsl plugin
[英]create a new Jenkins job by using Process DSL plugin groovy script
我需要通过从现有 Maven 项目复制配置来创建 Jenkins 新作业。 我想通过一个 groovy 脚本并使用 I have 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。 但是上面的脚本是作为 ** https://github.com/**ssh://git@stash.abc.com:1111/cegp/abc-automation-test/归档的人口存储库 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"')
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.