如何从gitlab CI管道中推送到存储库? [英] How do I push to a repo from within a gitlab CI pipeline?

查看:262
本文介绍了如何从gitlab CI管道中推送到存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的CI管道中,我正在生成一个工件public/graph.png,该工件可视化了我的代码的某些方面.在以后的步骤中,我想将其从CI管道中提交给仓库.这是.gitlab-ci.yml的相关部分:

In my CI pipeline I am generating an artifact public/graph.png that visualises some aspect of my code. In a later step I want to commit that to the repo from within the CI pipeline. Here's the pertinent part of .gitlab-ci.yml:

commit-graph:
  stage: pages
  script:
    - git config user.email "cipipeline@example.com"
    - git config user.name "CI Pipeline"
    - cd /group/project
    - mv public/graph.png .
    - git add graph.png
    - git commit -m "committing graph.png [ci skip]"
    - echo $CI_COMMIT_REF_NAME
    - git push origin HEAD:$CI_COMMIT_REF_NAME

当管道在gitlab中运行时,失败并显示:

When the pipeline runs within gitlab it fails with:

$ git config user.email"cipipeline@dhgitlab.dunnhumby.co.uk"
$ git config user.name"CI管道"
$ cd/group/project
$ mv public/graph.png.
$ git add graph.png
$ git commit -m"committing graph.png [ci skip]"
[分离的HEAD 22a50d1]提交graph.png [ci跳过]
已更改1个文件,0个插入(+),0个删除(-)
创建模式100644 graph.png
$ echo $ CI_COMMIT_REF_NAME
杰米/我的分支
$ git push origin HEAD:$ CI_COMMIT_REF_NAME
致命:无法访问" https://gitlab-ci-令牌:xxxxxxxxxxxxxxxxxx@example.com/group/project/project.git/':服务器证书验证失败. CAfile:/etc/ssl/certs/ca-certificates.crt CRLfile:无

$ git config user.email "cipipeline@dhgitlab.dunnhumby.co.uk"
$ git config user.name "CI Pipeline"
$ cd /group/project
$ mv public/graph.png .
$ git add graph.png
$ git commit -m "committing graph.png [ci skip]"
[detached HEAD 22a50d1] committing graph.png [ci skip]
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 graph.png
$ echo $CI_COMMIT_REF_NAME
jamiet/my-branch
$ git push origin HEAD:$CI_COMMIT_REF_NAME
fatal: unable to access 'https://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@example.com/group/project/project.git/': server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none

不确定我在做什么错,并且对SSL的了解不足以理解该错误.有人可以建议吗?

Not sure what I'm doing wrong and don't know enough about SSL to understand that error. Can anyone advise?

顺便说一下,我们自己托管了gitlab.

We are hosting gitlab ourselves by the way.

推荐答案

已解决.在推送之前发出git config --global http.sslverify "false"解决了该特定问题(它暴露了另一个问题,但这是另一个线程:))

Solved it. Issuing git config --global http.sslverify "false" prior to the push solved that particular problem (it exposed another problem but that's for another thread :) )

这篇关于如何从gitlab CI管道中推送到存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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