简体   繁体   English

Jenkins参数化管道失败

[英]Jenkins parameterized pipeline fail

How should pipeline/jenkinsfile syntax look to be triggered by parameterized trigger via curl for example? 例如,如何通过curl参数化触发器来触发pipeline / jenkinsfile语法?

I'm having the pipeline that starts with: 我正在开始的管道:

pipeline{  
    parameters {
        string(name: 'mycommitid', defaultValue: 'nocommit', description: 'my parameterized build')   
    }
    properties([
        parameters([
            string(defaultValue: 'nocommit', description: 'fas', name: 'mycommitid')
        ])
    ])
    node{...}
}

By setting this in the code my pipeline won't be triggered, only if I set it manually in build triggers section in jenkins. 通过在代码中设置此选项,仅当我在jenkins的build triggers部分中手动设置它时,才会触发我的管道。 But the goal is to use it in the multibranch pipelines and jenkinsfiles. 但目标是在多分支管道和jenkinsfiles中使用它。

The output I'm getting is (the hash here is some random number i typed as example): 我得到的输出是(这里的哈希是我键入的一些随机数作为示例):

git rev-parse 4364576456fgds467734ss344c^{commit} # timeout=10 
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.

Finished: FAILURE 

And having the commit passed, how do you advise should I build only that single revision? 通过提交后,您如何建议我仅构建该单个修订版?

When defining parameters in groovy pipeline script, you should define them before the groovy script, in the job configuration. 在groovy管道脚本中定义参数时,应在作业配置中的groovy脚本之前定义它们。

Once you created your parameters in the job configuration you can access them in the groovy, with the syntax ${env.PARAM} . 在作业配置中创建参数后,就可以使用语法${env.PARAM}在groovy中访问它们。

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

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