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

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

我目前正在尝试从 Jenkins Workflow 脚本中标记一个 repo.我尝试使用 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-06-02 08:36:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/440281.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:工作流   脚本   标记   Jenkins

发布评论

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

>www.elefans.com

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