我需要通过复制现有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 。 您能帮我解决这个问题吗?
答案 0 :(得分:1)
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"')
}
}