从提交消息中捕获软件包名称的脚本
我正在尝试设置一个gitlab ci管道来删除软件包,只有在批准合并请求后,管道才会触发,并从$ ci_commit_message捕获软件包名称并将其传递到删除命令以删除软件包。
但是,我在推送( decomm-xxx )期间给出的$ ci_commit_message被添加了一些额外的行( merge branch 'ipl1
'条件' 十字架 请参阅MR批准并合并后,请参见MERGE请求lkjdscjnjsdcdsnjkjkj“ )。
我如何从$ ci_commit_message中捕获包装名称,我最初给出( decomm-xxxxx ),我需要仅在“ decomm- ”之后打印文本,但我无法
对此进行任何帮助
I am trying to set up a GitLab ci pipeline to delete packages, the pipeline will trigger only after the merge request is approved, and the package name is captured from the $CI_COMMIT_MESSAGE and pass it to the delete command to delete the package.
But the $CI_COMMIT_MESSAGE which I have given during push (decomm-xxx) is been added with a few extra lines (Merge branch 'ipl1
' into 'Condition
'
decomm-zzz
See Merge request lkjdscjnjsdcdsnjkjkj") after the MR is approved and merged.
How exactly can I capture the package name from the $CI_COMMIT_MESSAGE which I originally gave (decomm-xxx), I need to print only the text after "decomm-" but I am not able to print it.
Any help on this would be much appreciated, thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许有几种方法:
更改提交消息
时添加的额外文本,以阻止Gitlab添加额外的文本,在Merge按钮下扩展下拉菜单。这将让您编辑合并提交消息:
编写一个更可靠的脚本
,您可以编写一个脚本以可靠地提取所需的文本。使用Regex可能是最合理的方法。
There's maybe a couple ways to do this:
Change the commit message
To stop GitLab from adding the extra text, expand the dropdown under the merge button. This will let you edit the merge commit message:
Write a more reliable script
Alternatively, you can write a script to reliably extract the text you need. Using regex is probably the most reasonable way to do this.