从 Jenkins 工作流脚本中标记存储库 [英] Tag a Repo from a Jenkins Workflow Script

查看:12
本文介绍了从 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 'https://<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 https://${env.GIT_USERNAME}:${env.GIT_PASSWORD}@<REPO> --tags")
}

这篇关于从 Jenkins 工作流脚本中标记存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆