What are you Looking for?
Populate the sidearea with useful widgets. It’s simple to add images, categories, latest post, social media icon links, tag clouds, and more.
P: Phone:
E: Email:
A: Address:
Some time ago, we started working for a client who didn’t have continuous integration. Who cares, would you say. We at Broscorp care a lot about the speed of delivery. Our main goal is to analyze the business need, build the solution, and deliver it with the highest possible quality.
Usually, software development companies care a lot about “building the solution” phase. Yes, it’s exciting, but business pays only for something that brings benefits. A built solution is not a benefit. Built, tested, and delivered on time solution is a benefit. That’s why when we realized that our new client doesn’t have CI/CD we planned all the activities needed to achieve it.
This is what we had:
Now I would like to list a set of steps needed to achieve our goal:
The very first, we need to collect credentials and variables from Azure App Service we need for Bitbucket pipelines.
Now let’s go and figure out all the values for these variables:
RESOURCE_GROUP and APP_NAME (title in the top left corner) you can find on your Azure App Services app Overview page.
5. Select the Cloud Shell button on the menu bar at the upper right.
az login
After that you are logged in.
az webapp deployment list-publishing-profiles –n <APP_NAME> –r <RESOURCE_GROUP>
Pick profile with publishMethod MSDeploy. Use userName and userPWD for AZURE_PB_USERNAME and AZURE_PB_PASSWORD.
az ad sp create-for-rbac –name
Notice that only users with Azure access role Owner can create the service principal.
Please don’t forget to save the service principal credentials shown after.
For AZURE_APP_ID, AZURE_PASSWORD and AZURE_TENANT_ID use appId, password and tenant values accordingly.
6. Set the Java version, Java container (Java SE for jar or Tomcat for war apps) and other Stack settings according to your project. You might need to change some Platform settings too. Platform settings Always on flag must be On.
9. You might need to restart your App Service. Select the Overview on the sidebar and click on the Restart button on the top panel to restart.
Now let’s get back to the bitbucket and set up the pipelines. Bitbucket pipelines are powerful thing to automate everything related to deployment. You can read about pipelines here: https://support.atlassian.com/bitbucket-cloud/docs/get-started-with-bitbucket-pipelines/
To make a long story short you have to create bitbucket-pipelines.yml file in the root of the repository branch.
The admin role for the repository is needed to perform the following actions.
Select Pipelines -> Deployments.
4. Set up the environment (env_name) and all variables you use in the bitbucket-pipelines.yml file for this environment:
AZURE_PB_USERNAME
AZURE_PB_PASSWORD
RESOURCE_GROUP
APP_NAME
AZURE_APP_ID
AZURE_PASSWORD
AZURE_TENANT_ID
Notice: Deployment to the production is a very important thing which should be avoided to happen occasionally. So it can be a good idea to restrict deployment to admins only.
6. Set up your automated build and deployment configuration by creating bitbucket-pipelines.yml file in the root of the repository.
Web Apps
The following command stands for web app deployment via Bitbucket microsoft/azure-web-apps-deploy:1.0.2 pipe:
– pipe: microsoft/azure-web-apps-deploy:1.0.2
variables:
AZURE_APP_ID: $AZURE_APP_ID
AZURE_PASSWORD: $AZURE_PASSWORD
AZURE_TENANT_ID: $AZURE_TENANT_ID
AZURE_RESOURCE_GROUP: $RESOURCE_GROUP
AZURE_APP_NAME: $APP_NAME
ZIP_FILE: ‘/opt/atlassian/pipelines/agent/build/repo_name/target/repo_zipname.zip’
All web apps should be assembled into a zip file (repo_zipname.zip)during the build.
Web Jobs
There are two types, continuous and triggered web jobs on Azure. They should be deployed into continuous and triggered folders.
The following command stands for continuous web job deployment:
curl -u ${AZURE_PB_USERNAME}:${AZURE_PB_PASSWORD} -X PUT https://${APP_NAME}.scm.azurewebsites.net/api/zip/site/wwwroot/App_Data/jobs/continuous/ –data-binary @webjob_repo_name/target/webjob_zipname.zip
For the web job in the root of the web job subrepository create the run.cmd file.Use JAVA_OPTS variable to override the predefined Spring active profile for jar.
4. Select the branch and the pipeline. For deployment, use develop branch and select custom: <env_name> pipeline if you have no other specific instructions.
6. Deployment is a manually triggered step, so you need to click the Deploy button when the step gets available in the pipeline.
Web Apps
Web Jobs
In this fast-changing environment it becomes essential to deliver results as fast as possible. Such things like continuous delivery decreases the time needed to release a new product/features to the market. If you would like to be on time with your new feature ask Broscorp on how to achieve this!