1
votes

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

git clone https://[email protected]/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?

2

2 Answers

1
votes
  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:[email protected]/usernameHere/projectNameHere
  4. If you use self-hosted agent, go to the agene machine, and remove the credential in Credential Manager.
0
votes

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.