<p>You can use a custom build container image for your pipeline with Maven and all of your other dependencies. You will need to: </p>

<ol>
<li>Create a Dockerfile that installs Maven and all other dependencies that you have</li>
<li>Build the image and upload it to a custom Azure Container Registry</li>
<li>Modify your YAML pipeline file to reference the new build image</li>
</ol>

<p>Sample:</p>

<pre><code>resources:
   containers:
     - container: build_container
       image: demoxyz.azurecr.io/pipeline-build-image:latest
       endpoint: AzureCR
       options: '-v /usr/bin/docker:/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock'
</code></pre>

<p>Here is an article that discusses the <a href="https://yuriburger.net/2019/03/04/use-your-own-build-container-image-to-create-containerized-apps/" rel="nofollow noreferrer">topic</a>. </p>

CC BY-SA 4.0
2019-08-27T16:39:08.490Z
2019-08-27T16:39:08.490Z
Preston Martin
<p>In my project we are using Azure DevOps in which we have a pipeline which</p>

<ul>
<li>pulls code from code repository</li>
<li>downloads Ubuntu container</li>
<li>installs Maven</li>
<li>downloads all the dependencies</li>
<li>then tries to build code</li>
</ul>

<p>With this approach, every time we commit code in the repository, new container gets downloaded and Maven dependencies are downloaded as well.</p>

<p>Downloading dependencies itself is taking 10+ minutes which is kind of frustrating.</p>

<p>Is there any way in which we can cut down this build time? We have couple of virtual machines in Azure, is it possible to tell Azure DevOps pipeline to use these virtual machines to build the code instead of using containers?</p>

<p>I am sorry if this question is too broad/generic but I am new to DevOps and Azure in general so I don't know specific terms from DevOps world.</p>

<p>Thanks,
Chandra</p>

<git><azure-devops><cicd><maven><java>
How to build Java project on existing virtual machine in Azure?
Shekhar
# How to build Java project on existing virtual machine in Azure?

(Asked by: username_0 on 2019-08-27)

In my project we are using Azure DevOps in which we have a pipeline which

* pulls code from code repository
* downloads Ubuntu container
* installs Maven
* downloads all the dependencies
* then tries to build code

With this approach, every time we commit code in the repository, new container gets downloaded and Maven dependencies are downloaded as well.

Downloading dependencies itself is taking 10+ minutes which is kind of frustrating.

Is there any way in which we can cut down this build time? We have couple of virtual machines in Azure, is it possible to tell Azure DevOps pipeline to use these virtual machines to build the code instead of using containers?

I am sorry if this question is too broad/generic but I am new to DevOps and Azure in general so I don't know specific terms from DevOps world.

Thanks,
Chandra

**Tags:** git, azure-devops, cicd, maven, java


---

## 1 answers

### Answer by username_1 on 2019-08-27. Score: 1

You can use a custom build container image for your pipeline with Maven and all of your other dependencies. You will need to: 

Create a Dockerfile that installs Maven and all other dependencies that you have
Build the image and upload it to a custom Azure Container Registry
Modify your YAML pipeline file to reference the new build image

Sample:
resources:
   containers:
     - container: build_container
       image: demoxyz.azurecr.io/pipeline-build-image:latest
       endpoint: AzureCR
       options: '-v /usr/bin/docker:/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock'

Here is an article that discusses the topic.


---

