Anki
Anki

Reputation: 1

Azure Devops CI pipeline unable to connect to a private repo to fetch a dependency to build an artifact

Maven build task -> There are few dependencies that are put in private repository. While running CI pipeline it is unable to connect to that private repo. to download the dependency and proceed.

  1. Is it related to firewall or service connection that needs to be created.
  2. Can we put those dependency in azure artifact and feed the CI pipeline from this at the time of cuild. Please help with a sample code for this.

Upvotes: 0

Views: 2406

Answers (1)

Levi Lu-MSFT
Levi Lu-MSFT

Reputation: 30343

If the private maven repository is hosted on a local server. You need to create a self-hosted agent on the local machine which has access to the private repository.

And you need to create a maven service connection in your azure devops project (Project settings-->Service connections under Pipelines-->New service connection-->select Maven).

Then you need to run your pipeline on your self-hosted agent(Choose the agent pool where your self-hosted agent resides), for the microsoft hosted agents cannot access to the private repository hosted on your local server. And add Maven Authenticate task to authenticate your private repository during the build. Select the maven service connection created in above step in field Credentials for repositories outside this organization/collection (also mavenServiceConnections in yaml format pipeline)

enter image description here


You can also put those dependencies in azure artifact feed. Please check this quick start to create a maven feed in your azure devops and publish your dependencies to it. And follow the instructions to set up your project by adding the repo to your pom.xml file.

Then you need to set the mavenFeedAuthenticate argument to true in your Maven task. (In Advanced settings of Classic UI task). Now you should be able to download the dependencies published to the azure artifacts feed in your pipeline.

enter image description here

However, another way to authenticate your feed is to use Maven Authenticate task. See below: Select your maven feed to authenticate in the pipeline.

enter image description here

If you want to consume the maven repositories outside current organization. You need to follow above steps of creating a maven service connection for this repository.

Upvotes: 1

Related Questions