-1

Within Azure DevOps I am trying to create a Command Line Script which is pushing the actual DevOps Repo to GitLab.

git clone https://xxxx@dev.azure.com/xxxx/DBS/_git/xxx
git remote add --mirror=fetch secondary https://oauth2:%pat%@gitlab.com/username/gitlabrepo.git
git fetch origin
git push secondary --all

In the env parameter %pat% I am referencing the Personal Access Token from GitLab. When running the pipeline with the Comman Line Script I am getting the following error:

start to push repo to gitlab
Cloning into 'gitlabrepo'...
remote: HTTP Basic: Access denied
fatal: Authentication failed for 'https://gitlab.com/***/gitlabrepo.git/'
##[debug]Exit code: 128
##[debug]Leaving Invoke-VstsTool.
##[error]Cmd.exe exited with code '128'.

How could be this achieved?

riQQ
  • 9,878
  • 7
  • 49
  • 66
Pirvu Georgian
  • 657
  • 1
  • 12
  • 37

2 Answers2

1
  1. Make sure the commands work locally in the git bash.
  2. Run git config --global--unset credential.helper command git add command
  3. If the issue persists, try run git remote set-url origin https://usernameHere:personalAccessTokenHere@gitlab.com/usernameHere/projectNameHere
  4. If you use self-hosted agent, go to the agene machine, and remove the credential in Credential Manager.
Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39
0

The Avure DevOps agent is running this on a ubuntu-18.04 Machine. It seems that the connection to gitlab with the PAT fails because this is a corporate gitlab account and have some firewall restriction.Because from my local machine connected via VPN to the corporate network it's working. Git bash locally works fine. Error is because this machine started by the Pipeline Agent is not into the VPN of the company.

Pirvu Georgian
  • 657
  • 1
  • 12
  • 37