'how to integrate gitlab repository to azure devops

We are using git (on premises gitlab) as source controle, Can some one guide me how I can integrate private gitlab repo to my azure devops organization to push the artifacts. I have tried by using option other git in azure devops with service connection but it did’t worked I will the paste the error log here.

Error log:

An exception occurred while polling the repository. Error: Microsoft.TeamFoundation.Build2.Server.Extensions.ExternalConnectorException: The remote name could not be resolved:



Solution 1:[1]

In GitLab, there are two features that enable this integration:

  1. GitLab CI/CD for external repositories
  2. Remote repository mirroring

How to set up the integration :

  1. Create a new project in GitLab by clicking the New Project button enter image description here

  2. Choose the ‘CI/CD for external repo’ tab, and click on Repo by URL. enter image description here

  3. Open your repository in Azure DevOps and click Clone enter image description here

  4. Copy the URL. If your repository is private, you will need to generate Git credentials – just click this button and copy the username and password. enter image description here

  5. Paste the URL in GitLab under the Git repository URL, give it a name, set the visibility level, and click create project. Add the username and password in case your Azure DevOps repository is private. Note: The repository must be accessible over http://, https:// or git://. When using the http:// or https:// protocols, please provide the exact URL to the repository. HTTP redirects will not be followed. enter image description here

  6. Your project is now successfully Mirrored to GitLab. Now branches, tags, and commits will be synced automatically to GitLab.

  7. To configure a CI/CD pipeline there are two options:

Before pushing your first commit, open the CI/CD settings in GitLab and enable Auto DevOps. It will set the CI/CD configuration, so each commit in Azure Repos will trigger a CI/CD pipeline in GitLab which will build, test, and deploy your app.

enter image description here

Alternatively, in case you want to define the pipeline configuration yourself instead of using the Auto DevOps, add .gitlab-ci.yml file to your repository root directory. The Yaml code should include your CI/CD definitions. Once this file is included in the root directory a CI/CD pipeline will be triggered for each commit. If you are not familiar with .gitlab-ci.yml, start by creating a file with the name .gitlab-ci.yml and paste the below code to it. This code includes build and test stages, and a job that displays text to the console in each stage. Later on you can add additional scripts to each job, and also add additional jobs and stages. To create more complex pipelines, you can use the pipeline templates that are shipped with GitLab instead of starting it from scracth.

stages:
  - build
  - test 
  
build:
  stage: build
  script:
    - echo "Build job"

test:
  stage: test
  script:
    - echo "Test job"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jerry King