Skip to main content Explore View all products (200+) Microsoft Foundry Azure Copilot GitHub Copilot Azure Kubernetes Service (AKS) Azure Cosmos DB Azure Database for PostgreSQL Azure Arc Microsoft Fabric Linux virtual machines in Azure Foundry Models Foundry Agent Service Foundry IQ Foundry Tools Foundry Control Plane Observability in Foundry Control Plane Azure OpenAI in Foundry Models Azure Speech in Foundry Tools Azure Machine Learning View all databases Azure Cosmos DB Azure DocumentDB Azure SQL Azure Database for PostgreSQL Azure Managed Redis Microsoft Fabric Azure Databricks Linux virtual machines in Azure Windows Server on Azure Azure Functions Azure Virtual Machine Scale Sets Azure API Management Azure Container Apps Azure Kubernetes Service (AKS) Azure Kubernetes Fleet Manager Azure Container Registry Azure Red Hat OpenShift Azure Container Instances Azure Container Storage Azure Arc Azure Local Microsoft Defender for Cloud Azure Monitor Microsoft Sentinel Azure Migrate View all solutions (40+) Cloud solutions for small and medium businesses Cloud migration and modernization center Data analytics for AI Azure Databases AI apps and agents Microsoft Marketplace Microsoft Sovereign Cloud AI apps and agents Responsible AI with Azure AI Infrastructure Data analytics for AI Machine learning operations (MLOps) Low-code application development on Azure Integration Services Serverless computing DevOps Migration and modernization center .NET apps migration Databases on Azure Linux on Azure Oracle on Azure SAP on the Microsoft Cloud Adaptive cloud High-performance computing (HPC) Infrastructure as a service (IaaS) Resiliency Azure Essentials Frontier Accelerate for Azure FinOps on Azure Microsoft Marketplace Azure pricing overview Create an Azure account Free Azure services Flexible purchase options Pricing calculator FinOps on Azure Maximize ROI from AI Azure savings plans Azure reservations Azure Hybrid Benefit Virtual Machines Azure SQL Microsoft Foundry Microsoft Fabric Azure Kubernetes Service (AKS) Microsoft Defender for Cloud View more Software Development Companies Microsoft Marketplace Find a partner Resources for Azure partners Get started with Azure Customer stories Analyst reports, white papers, and e-books Videos Learn more about cloud computing Documentation Explore Azure portal Developer resources Quickstart templates Resources for startups Developer community Students Azure for partners Blog Events and Webinars Learn Support Contact Sales Get started with Azure Sign in

Last year at Jenkins World, we announced Jenkins on Azure support for Kubernetes. We shipped the Azure Container Agent which allows you to scale out to Azure and run a Jenkins Agent on Azure Container Instances (ACI) and/or Azure Kubernetes Service (AKS). Using the Kubernetes Continuous Deploy or Deploy to Azure Container Services (AKS) plugins, you can deploy containers to Kubernetes.

Back in April, we published a blog post in Kubernetes.io sharing with the community how to achieve Blue/Green deployment to Azure Container Services (AKS). Some questions remained to be answered though:

  • What if I need to build a Docker image when I use ACI as my Jenkins build agent?
  • If I run Docker Build on AKS, is it secured?

Earlier this year, the Azure Container Registry team released a preview of a native container build capability called Azure Container Registry (ACR) Build, which solves just these problems. One of the best things about ACR build is you only pay for the compute you use to build your images.

Build from local directory

Let’s say you have an existing pipeline that uses Maven to build your Java project and then deploys to AKS:

node {
    /* … snip… */

    stage('Build') {
    sh 'mvn clean package'
    withCredentials([usernamePassword(credentialsId: env.ACR_CRED_ID, usernameVariable: 'ACR_USER', passwordVariable: 'ACR_PASSWORD')]{
      sh 'docker login -u $ACR_USER -p $ACR_PASSWORD https://$ACR_SERVER'
      // build image
      def imageWithTag = "$env.ACR_SERVER/$env.WEB_APP:$env.BUILD_NUMBER"
      def image = docker.build imageWithTag
      // push image
      image.push()
    }
    stage(‘Deploy’) {
      /*… snip… */
    } 
}

Since ACR Build supports builds from your local directory (in this case the build server local directory), you can replace the five lines of code with one line in your pipeline like this:

node {
  /* … snip… */
  stage('Build') { 
    sh 'mvn clean package'

    acrQuickBuild azureCredentialsId: 'principal-credentials-id',
                  resourceGroupName: env.ACR_RES_GROUP,
                  registryName: env.ACR_NAME,
                  platform: "Linux",
                  dockerfile: "Dockerfile",
                  imageNames: [[image: "$env.ACR_REGISTRY/$env.IMAGE_NAME:$env.BUILD_NUMBER"]]
  }  
  stage(‘Deploy’) {
    /*… snip… */
  }
}

The benefits

  • Apart from AKS, you can now run this build pipeline in ACI.
  • ACR Build enables network close, multi-tenant builds, reducing the network distance, and ensuring reliability of Docker push to the registry.
  • Best yet, you no longer need to get into another debate with your peers about whether it is safe to run Docker on Docker.

Build based on git commits

What if you are setting up a new pipeline and just want to trigger build upon code commit? Fear not, ACR Build supports commit based builds. We set up a sample Jenkins file that allows you to build a Spring Boot Web App in ACR with deployment to AKS. In this case, once code is committed to GitHub, Jenkins will trigger the build in ACR, you can run tests (not covered in sample) and then deploy the Docker image to production. Simply follow the instructions on building a Docker image from git repo in ACR then deploying to AKS using Jenkins.

We will preview Azure ACR plugin at Jenkins World 2018. We will also have a few demos showing how to deploy to App Service with Tomcat and Java SE.

Please drop by the Azure Jenkins booth, see a demo, or chat with us about how you are integrating Jenkins with Azure. We are always looking for feedback and to hear more about your build systems.

WE ARE MICROSOFT

Explore Microsoft Foundry

The future of AI starts here. Envision your next great AI app with the latest technologies. Get started with Azure.