简体   繁体   English

传递参数 jenkins MultiBranch Action Triggers Plugin

[英]Pass parameters jenkins MultiBranch Action Triggers Plugin

I am using this jenkins MultiBranch Action Triggers Pluginhttps://github.com/jenkinsci/multibranch-action-triggers-plugin我正在使用这个 jenkins 多分支动作触发器插件https://github.com/jenkinsci/multibranch-action-triggers-plugin

I need to trigger another job when a branch is deleted.当一个分支被删除时,我需要触发另一个工作。 The trigger is working fine, however from this new job that gets triggered I need to pass the branch name that was deleted.触发器工作正常,但是从这个被触发的新工作中,我需要传递已删除的分支名称。 So I am having a hard time finding out how to pass parameters from a deleted branch to the job that was triggered.所以我很难找到如何将参数从已删除的分支传递到触发的作业。

Any help will be very appreciated.任何帮助将不胜感激。

According to the documentation of the plugin:根据插件的文档:

Branch/Pipeline name value is passed to the job by the parameter named "SOURCE_PROJECT_NAME".分支/管道名称值通过名为“SOURCE_PROJECT_NAME”的参数传递给作业。 This parameter will have the name of the Pipeline/Branch which is created by Multi Branch Pipeline.此参数将具有由多分支管道创建的管道/分支的名称。 For example if you only have master branch in your repository, this value will be "master".例如,如果您的存储库中只有 master 分支,则此值将为“master”。

So go to your pipeline which is run after a branch is deleted, go to configure -> general, and check the "this project is parameterized" box.因此,将 go 添加到删除分支后运行的管道,将 go 添加到配置 -> 常规,并选中“此项目已参数化”框。 fill the form as below:填写表格如下: 参数配置

In pipeline script, try to print SOURCE_PROJECT_NAME在管道脚本中,尝试打印SOURCE_PROJECT_NAME

node { 
     println(SOURCE_PROJECT_NAME)
}

This should print out your deleted branch name.这应该打印出您删除的分支名称。

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

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