Search code examples
azure-devopsgitlabdevopsgitlab-cigitlab-api

Azure DevOps push to GitLab


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?


Solution

  • 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.