使用 Process DSL 插件 groovy 脚本创建一个新的 Jenkins 作业

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"')
    }
}

按照上面的配置,在新作业Source code Management中,Repository URL应该是ssh:/ /git@stash.abc.com:1111/cegp/abc-automation-test.git 因为我只需要执行 SSH。 但是上面的脚本是 population Repository URL filed as **https://github.com/**ssh://git@stash.abc.com:1111/cegp/abc-automation-test/ 这是错误的。 你能帮我解决一下吗。

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"')
        }
    }