在Post Step中使用相同的http git凭证作为Shell脚本中的克隆 [英] Use same http git credentials as for cloning in a Shell script in a Post Step

查看:215
本文介绍了在Post Step中使用相同的http git凭证作为Shell脚本中的克隆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让我们的发布过程自动化,并且我有一个关于Maven项目的Jenkins构建作业:


  • 克隆一个Git仓库配置Jenkins凭据(用户名/密码)
  • 为构建执行一些Maven命令
  • 配置一个执行一些附加Git命令的Post Step:merge ,tag,push



如果我运行版本,在执行我的 Post Step Shell脚本时收到以下错误:

  fatal:无法读取'https:// mygitserver'的用户名:输入/输出错误
code>

Git Repo服务器使用HTTP进行身份验证。



日志我可以看到Jenkins使用.gitcredentials处理身份验证:使用.gitcredentials设置凭据
$ b

  git config --local credential.username jenkins#timeout = 10 
> git config --local credential.helper store --file = / tmp / git2442727044778485.credentials#timeout = 10

我现在想要重新使用这些凭证存储,因为它们是在我的构建开始时创建的,但在克隆后又被删除。



这是可能的吗?我需要自己用Credentials Binding Plugin等来处理这个问题吗?



感谢您的帮助。


I want to automate our Release process and I have a following Jenkins build job for a Maven project:

  • Cloning a Git repo with configured Jenkins Credentials (username/password)
  • Executing some Maven commands for the build
  • Having a Post Step configured which executes some additional Git commands: merge, tag, push

If I run the build I receive following error during executing my Post Step Shell script:

fatal: could not read Username for 'https://mygitserver': Input/output error

The Git Repo server uses HTTP for Authentication.

In the Console Log I can see that Jenkins uses .gitcredentials to handle the Authentication:

using .gitcredentials to set credentials
> git config --local credential.username jenkins # timeout=10
> git config --local credential.helper store --file=/tmp/git2442727044778485.credentials # timeout=10

I would like now to reuse actually these credential store because they are created at the beginning of my build, but are removed again after cloning.

Is this somehow possible or do I need to handle this somehow by myself with the "Credentials Binding Plugin", etc.?

Thanks for your help.

解决方案

Because I haven't found yet any solution to reuse the initial Git credentials from the clone command at the beginning of my build, I have just used now the Jenkins Credentials Binding plugin and created a own credentials store for my custom git commands in the Post Step.

这篇关于在Post Step中使用相同的http git凭证作为Shell脚本中的克隆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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