简体   繁体   English

詹金斯管道技术

[英]Jenkins pipeline groovy

Below is my simple jenkins pipeline groovy script by which it will create a pipeline with these 2 stages and the jobs we want to build,I want the job names in that for build and code analysis should get updated in the script under job configuration everytime by taking the data from the UI where the user will just provide the build jobname and code analysis jobname using Eclipse - 下面是我简单的jenkins管道groovy脚本,它将通过这两个阶段创建管道,并创建我们要构建的作业。我希望用于构建和代码分析的作业名称应每次在作业配置下的脚本中得到更新从用户界面获取数据,用户将仅使用Eclipse提供构建作业名称和代码分析作业名称-

jenkinsfile script :- jenkinsfile脚本:-

stage('Build'){

    build job: 'job1'

}

stage('Code_Analysis'){

    build job: 'job2'

}

詹金斯->新项目->管道作业图片

jenkins管道作业的脚本图像

While your question is a bit vague, I guess the problem is that your Jenkinsfile does not include the node statement: 虽然您的问题有点含糊,但我想问题是您的Jenkinsfile不包含node语句:

node {
    stage('Build'){
        build job: 'job1'
    }

    stage('Code_Analysis'){
        build job: 'job2'
    }
}

So you want to pass job name as parameters. 因此,您想将作业名称作为参数传递。 You can use string parameter eg JOB1 & JOB2. 您可以使用字符串参数,例如JOB1&JOB2。 Then pass that to build job as it is. 然后将其传递以按原样构建作业。 No need of curly braces or inverted commas like shown below- 不需要花括号或逗号反转,如下所示-

stage('Build'){
    build job: JOB1
}
stage('Code_Analysis'){
    build job: JOB2
}

我想可以在jenkins管道中使用$ {name}变量来使用作业名称

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM