从appveyor构建推送到远程gitlab Git仓库

问题描述 投票:0回答:1

我尝试按照这里的步骤进行 https:/www.appveyor.comdocshow-togit-push

我在为gitlab添加访问令牌时卡住了,我试了下 ps: Add-Content "$HOME\.git-credentials" "https://$($env:access_token):[email protected] 但这不工作。我得到了 fatal: Authentication failed for https://gitlab.com我的appveyor yml文件看起来是这样的

branches:
  only:
    - master

environment:
  access_token:
    # EDIT the encrypted version of your GitHub access token
    secure: ********************************

on_success:
  - git config --global credential.helper store
  # EDIT your Git email and name
  - git config --global user.email *****@l***.com
  - git config --global user.name As**** A***
  - ps: Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:access_token):[email protected]`n"
  - git checkout -f master
  - git clean  -d  -f .
  - xcopy ..\output output /E /Y /I

  # EDIT the origin of your repository - have to reset it here because AppVeyor pulls from SSH, but GitHub won't accept SSH pushes
  - git remote set-url origin https://gitlab.com/****/project.git
  - git add .
  - git commit -a -m "Commit from AppVeyor to gitlab"
  - git push 

要怎么改才能让它在gitlab上运行?

gitlab access-token appveyor
1个回答
0
投票

尝试添加 -NoNewLine 到命令设置结束 .git-credentials:

  - ps: Add-Content -Path "$HOME\.git-credentials" -Value "https://oauth2:$($env:access_token)@gitlab.com`n" -NoNewline

这个例子最近因为Git 2.26.2加强了安全性而改变。

另外请注意,我已经把值改成了传递凭证,就像你的例子一样。https://oauth2:$($env:access_token)@gitlab.comn`

© www.soinside.com 2019 - 2024. All rights reserved.