Submitted by superadmin on Mon, 03/11/2019 - 15:28

If you've been following developments at Microsoft during the tenure of CEO Satya Nadella, it is likely you have heard him say "Microsoft Loves Open Source!"

Here at SNP, we did not need to be convinced of the value open source tools bring to our customers. A case in point is Jenkins, an open source automation server that has been a leader in the DevOps tooling marketplace. For several years, Jenkins has been SNP's go-to software for continuous integration and continuous delivery (CI/CD) pipelines.

For its part, Microsoft is also a Jenkins fan, having an entire section of its Azure documentation devoted to Jenkins on Azure. As well, there are tutorials to cover specific use cases in the Azure context, such as to deploy from GitHub to Azure Kubernetes Service (AKS) with Jenkins.

To get started with Jenkins in Azure, Microsoft provides a guide to creating a Jenkins server on an Azure Linux VM from the Azure portal. This is all well and good, but this requires love and attention to a virtual machine, and that may not be your cup of tea. Jenkins as a service may be more to your liking. For this one can deploy Jenkins on Azure Web App for Containers. (At this time, put on your finest British accent, and repeat after me, "Jenkins at your service on Azure, Madam".)

In the open source spirit, SNP has contributed a Docker image solution on GitHub titled Jenkins on Azure Web App for Containers. You can fork the Git repo to use as the basis for your own container image.

 

What follows is a step by step guide to deploy Jenkins on Azure Web App for Containers.

 

Get the Git Repository

Visit Jenkins on Azure Web App for Containers to clone or fork the repo. Read the README.md file, of course, and review the files in the repository.

 

Build an Image, Push to a Container Registry

The following steps assume you have Docker installed in your development environment.

In your favorite terminal, e.g. Git Bash, switch to the directory in which you cloned the repository.

 

At the command link, enter the Docker build command, for example:

docker build -t mikesacr.azurecr.io/jenkinsonazure:v1 .

 

List images to verify the build:

docker images

 

Run the image locally, for example:

docker run -p 8080:8080 mikesacr.azurecr.io/jenkinsonazure:v1

 

Push the image to a container repository. For example, using Azure Container Registry:

docker login mikesacr.azurecr.io -u myusername docker push mikesacr.azurecr.io/jenkinsonazure:v1

 

Once complete, a sha256 value with a unique identifier for your image is displayed, for example:

 

sha256 value for container image

 

This sha256 is also visible in the Azure Portal, for example:

 

Container image SHA example as viewed in Azure Portal.

 

Deploy your Container Image on Web App for Containers

The following steps assume you have an Azure Subscription and an App Service Plan.

Create a Web App for Containers Resource

In Azure Portal, click "Create a resource", then search for "Web App for Containers":

Steps to Create a Web App for Containers resources in the Azure Portal.

 

This will open a Web App for Containers resource information blade. Click on the "Create" button at the bottom of the blade:

 

Web App for Containers resource information blade in Azure Portal.

 

Next, fill in values for the parameters required to create your resource.

  1. Enter a unique App name
  2. Select your Azure Subscription
  3. Select a Resource Group. I recommend a new resource group because the life cycle of your Jenkins app will probably be independent of that of other applications.
  4. Select "Linux" as your OS
  5. Select an App Service plan/Location. If you have not already created a Service Plan, that's OK. A new one can be created from here. The Service Plan should be in the same region as the Resource Group. Check this list of locations that support the Web App for Containers.
  6. Configure container. Here we identify the container registry and container image to be deployed to the Web App. Click the "Apply" when done filling in this blade.
  7. Click the "Create" button

 

Web App for Containers parameter entry blade in Azure Portal.

 

Note: Alternatively, the preceding steps can be accomplished using the Azure CLI.

When the deployment completes, you should see your new Resource Group and new Web App resource in Azure Portal. Click on the Web App Resource. There are a few steps you need to complete before running your Jenkins application, as noted in the README.md file.

Web App Configuration Steps

  1. Ensure that the WEBSITES_ENABLE_APP_SERVICE_STORAGE app setting to "true" in the Application settings blade of the Web App.

    Application setting for WEBSITES_ENABLE_APP_SERVICE_STORAGE
  2. Manually create the jenkins_home directory in the Web App /home directory
    before you run the container and install Jenkins. This can be done from the Kudu Bash screen or from an FTPS session.

    Screen capture of web app home directory from FileZilla FTP client.

Run your Jenkins Container

From the Web App Overview blade, click on the URL to run your Jenkins instance. After a brief initialization period, you should be presented with the Unlock Jenkins screen.

You are on your own from here, but keep in mind the "Gotchas" we have documented in the repo's README.md file.

Jenkins Unlock Jenkins screen

 

In Closing

If you have questions and suggestions to improve the solution, we are happy to receive issues and pull requests. Contact SNP here.

 

Blog image
Jenkins on Azure

Jenkins At Your Service On Azure

March 11, 2019 | By Michael Brooks

Jenkins on Azure

If you've been following developments at Microsoft during the tenure of CEO Satya Nadella, it is likely you have heard him say "Microsoft Loves Open Source!"

Here at SNP, we did not need to be convinced of the value open source tools bring to our customers. A case in point is Jenkins, an open source automation server that has been a leader in the DevOps tooling marketplace. For several years, Jenkins has been SNP's go-to software for continuous integration and continuous delivery (CI/CD) pipelines.

For its part, Microsoft is also a Jenkins fan, having an entire section of its Azure documentation devoted to Jenkins on Azure. As well, there are tutorials to cover specific use cases in the Azure context, such as to deploy from GitHub to Azure Kubernetes Service (AKS) with Jenkins.

To get started with Jenkins in Azure, Microsoft provides a guide to creating a Jenkins server on an Azure Linux VM from the Azure portal. This is all well and good, but this requires love and attention to a virtual machine, and that may not be your cup of tea. Jenkins as a service may be more to your liking. For this one can deploy Jenkins on Azure Web App for Containers. (At this time, put on your finest British accent, and repeat after me, "Jenkins at your service on Azure, Madam".)

In the open source spirit, SNP has contributed a Docker image solution on GitHub titled Jenkins on Azure Web App for Containers. You can fork the Git repo to use as the basis for your own container image.

 

What follows is a step by step guide to deploy Jenkins on Azure Web App for Containers.

 

Get the Git Repository

Visit Jenkins on Azure Web App for Containers to clone or fork the repo. Read the README.md file, of course, and review the files in the repository.

 

Build an Image, Push to a Container Registry

The following steps assume you have Docker installed in your development environment.

In your favorite terminal, e.g. Git Bash, switch to the directory in which you cloned the repository.

 

At the command link, enter the Docker build command, for example:

docker build -t mikesacr.azurecr.io/jenkinsonazure:v1 .

 

List images to verify the build:

docker images

 

Run the image locally, for example:

docker run -p 8080:8080 mikesacr.azurecr.io/jenkinsonazure:v1

 

Push the image to a container repository. For example, using Azure Container Registry:

docker login mikesacr.azurecr.io -u myusername docker push mikesacr.azurecr.io/jenkinsonazure:v1

 

Once complete, a sha256 value with a unique identifier for your image is displayed, for example:

 

sha256 value for container image

 

This sha256 is also visible in the Azure Portal, for example:

 

Container image SHA example as viewed in Azure Portal.

 

Deploy your Container Image on Web App for Containers

The following steps assume you have an Azure Subscription and an App Service Plan.

Create a Web App for Containers Resource

In Azure Portal, click "Create a resource", then search for "Web App for Containers":

Steps to Create a Web App for Containers resources in the Azure Portal.

 

This will open a Web App for Containers resource information blade. Click on the "Create" button at the bottom of the blade:

 

Web App for Containers resource information blade in Azure Portal.

 

Next, fill in values for the parameters required to create your resource.

  1. Enter a unique App name
  2. Select your Azure Subscription
  3. Select a Resource Group. I recommend a new resource group because the life cycle of your Jenkins app will probably be independent of that of other applications.
  4. Select "Linux" as your OS
  5. Select an App Service plan/Location. If you have not already created a Service Plan, that's OK. A new one can be created from here. The Service Plan should be in the same region as the Resource Group. Check this list of locations that support the Web App for Containers.
  6. Configure container. Here we identify the container registry and container image to be deployed to the Web App. Click the "Apply" when done filling in this blade.
  7. Click the "Create" button

 

Web App for Containers parameter entry blade in Azure Portal.

 

Note: Alternatively, the preceding steps can be accomplished using the Azure CLI.

When the deployment completes, you should see your new Resource Group and new Web App resource in Azure Portal. Click on the Web App Resource. There are a few steps you need to complete before running your Jenkins application, as noted in the README.md file.

Web App Configuration Steps

  1. Ensure that the WEBSITES_ENABLE_APP_SERVICE_STORAGE app setting to "true" in the Application settings blade of the Web App.

    Application setting for WEBSITES_ENABLE_APP_SERVICE_STORAGE
  2. Manually create the jenkins_home directory in the Web App /home directory
    before you run the container and install Jenkins. This can be done from the Kudu Bash screen or from an FTPS session.

    Screen capture of web app home directory from FileZilla FTP client.

Run your Jenkins Container

From the Web App Overview blade, click on the URL to run your Jenkins instance. After a brief initialization period, you should be presented with the Unlock Jenkins screen.

You are on your own from here, but keep in mind the "Gotchas" we have documented in the repo's README.md file.

Jenkins Unlock Jenkins screen

 

In Closing

If you have questions and suggestions to improve the solution, we are happy to receive issues and pull requests. Contact SNP here.

 

Headshot of Michael Brooks
Author:
Michael Brooks

Michael Brooks is the Director of Development at SNP Technologies. In his role, Mike provides technical direction and oversight over contracts for application development, cloud migration, and DevOps projects. Throughout a project's life-cycle Mike engages in essential consultation with customer stakeholders and works with internal project managers and engineering teams to ensure alignment with customer objectives. Catch up with Mike at an upcoming SNP Event…