小编典典

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

jenkins

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

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

是否有一个现有步骤可用于标记存储库或解决凭据问题?


阅读 356

收藏
2020-07-25

共1个答案

小编典典

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

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

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")
}
2020-07-25