Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用ProcessDSL插件groovy脚本创建一个新的Jenkins作业_Jenkins_Jenkins Pipeline_Jenkins Plugins_Jenkins Groovy - Fatal编程技术网

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

使用ProcessDSL插件groovy脚本创建一个新的Jenkins作业,jenkins,jenkins-pipeline,jenkins-plugins,jenkins-groovy,Jenkins,Jenkins Pipeline,Jenkins Plugins,Jenkins Groovy,我需要通过复制现有maven项目中的配置来创建Jenkins新作业。 我想通过groovy脚本和IhaveProcessDSL插件来实现这一点。我已经编写了下面的脚本,它能够创建一个新的作业,但是我遇到了GIT SSH URL的问题 String gitRepository = 'ssh://git@stash.abc.com:1111/cegp/abc-automation-test' String buildBranch = 'develop' String projectName = 'A

我需要通过复制现有maven项目中的配置来创建Jenkins新作业。 我想通过groovy脚本和IhaveProcessDSL插件来实现这一点。我已经编写了下面的脚本,它能够创建一个新的作业,但是我遇到了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。 但是上面的脚本是population存储库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"')
        }
    }
字符串gitRepository=ssh://git@stash.abc.com:/cegp/gsc自动化测试' 字符串buildBranch='developer' 字符串projectName='APMSmokeTesting' 字符串credentialIDGithub='61668d1b-3336-4c4d-90d7-721017049e36' //工作定义 mavenJob(项目名称){ 对数旋转器{ numToKeep(20) } 包装纸{ 预构建清理() } description('构建Java项目:'+gitRepository) 供应链管理{ 吉特{ 分行(建筑分行) 遥远的{ url(gitRepository) 证书(credentialIDGithub) } } } 触发{ scm(“@daily”) } 包装纸{ 目标('clean verify-Dtags=“APMSmokeTesting”') } }
您是否需要在运行时创建新作业?是的,我将读取一个文件以获取作业名称/我将获取的任何作业名称我将使用相同的名称创建作业请添加有关您的要求的更多详细信息。基于文件创建新作业时,原始作业和复制的作业之间有什么区别?我试图了解,为了在两个作业之间改变
参数
,您是否真的需要制作作业副本。可能还有其他的方法来实现你所需要的。一些注意事项-作业可能嵌套在多个文件夹中,因此您尝试
query
jenkins以
find
找到正确的作业,并将
config.xml
复制到具有新名称的新作业中。这是你的要求吗?如果你的建议有效,那么DSL也能完成这项工作,这将是很重要的。谢谢管道乔恩