从Jenkins工作流程脚本标记存储库

编程入门 行业动态 更新时间:2024-10-12 12:28:56
本文介绍了从Jenkins工作流程脚本标记存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我目前正在尝试从Jenkins Workflow脚本中标记存储库.我尝试使用sh步骤,但是由于未设置凭据而导致问题.

I'm currently trying to tag a repo from a Jenkins Workflow script. I've tried using a sh step but this runs into problems because of credentials not being set.

fatal: could not read Username for '<repo>': Device not configured

是否存在可用于标记存储库或解决凭证问题的现有步骤?

Is there an existing step that can be used either to tag a repo or to get round the credentials problem?

推荐答案

我已经通过使用凭据绑定插件提供的withCredentials步骤设法使此工作正常进行.

I've managed to get this working by using the withCredentials step provided by the credentials binding plugin.

这不是很好,因为它涉及在URL中全部指定,但是这些值在控制台输出中被屏蔽.

Its not great because it involved specifying it all in the URL but these values are masked in the console output.

withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'MyID', usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD']]) { sh("git tag -a some_tag -m 'Jenkins'") sh("git push ${env.GIT_USERNAME}:${env.GIT_PASSWORD}@<REPO> --tags") }

更多推荐

从Jenkins工作流程脚本标记存储库

本文发布于:2023-11-28 12:40:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642435.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   工作流程   标记   Jenkins

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!