Build with Jenkins in Azure
Set Up Jenkins Master
Create the Jenkins VM from the solution template
Open the marketplace image for Jenkins in your web browser and select GET IT NOW from the left-hand side of the page. Review the pricing details and select Continue, then select Create to configure the Jenkins server in the Azure portal.
In the Configure basic settings tab, fill in the following fields:
- Use Jenkins for Name.
- Enter a User name. The user name must meet specific requirements.
- Select Password as the Authentication type and enter a password. The password must have an upper case character, a number, and one special character.
- Use myJenkinsResourceGroup for the Resource Group.
- Choose the East US Azure region from the Location drop-down.
Select OK to proceed to the Configure additional options tab. Enter a unique domain name to identify the Jenkins server and select OK.
Once validation passes, select OK again from the Summary tab. Finally, select Purchase to create the Jenkins VM. When your server is ready, you get a notification in the Azure portal:
Connect to Jenkins
Navigate to your virtual machine (for example, http://jenkins2517454.eastus.cloudapp.azure.com/) in your web browser. The Jenkins console is inaccessible through unsecured HTTP so instructions are provided on the page to access the Jenkins console securely from your computer using an SSH tunnel.
Set up the tunnel using the
ssh command on the page from the command line, replacing
username with the name of the virtual machine admin user chosen earlier when setting up the virtual machine from the solution template.
ssh -L 127.0.0.1:8080:localhost:8080 <username>@<public DNS name of instance you just created>
After you have started the tunnel, navigate to http://localhost:8080/ on your local machine.
Get the initial password by running the following command in the command line while connected through SSH to the Jenkins VM.
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Unlock the Jenkins dashboard for the first time using this initial password.
Select Install suggested plugins on the next page and then create a Jenkins admin user used to access the Jenkins dashboard.
The Jenkins server is now ready to build code.
Create your first job
Select Create new jobs from the Jenkins console, then name it mySampleApp and select Freestyle project, then select OK.
Select the Source Code Management tab, enable Git, and enter the following URL in Repository URL field:
Select the Build tab, then select Add build step, Invoke Gradle script. Select Use Gradle Wrapper, then enter
complete in Wrapper location and
build for Tasks.
Select Advanced.. and then enter
complete in the Root Build script field. Select Save.
Build the code
Select Build Now to compile the code and package the sample app. When your build completes, select the Workspace link for the project.
complete/build/libs and ensure the
gs-spring-boot-0.1.0.jar is there to verify that your build was successful. Your Jenkins server is now ready to build your own projects in Azure.
Update Jenkins DNS
Make sure you update the Jenkins DNS name in Managed Jenkins -> Configure System -> Administrative monitors configuration -> Jenkins URL. Otherwise, the agent won’t be able to connect with the master.
Since the slave/agent connects with master via JNLP, make sure JNLP is allowed. In Jenkins, under Configure Global Security -> TCP port for JNLP agents, select
Fixed and specify a port, for example,
Make sure you add a corresponding inbound security rule for the Jenkins master. In Azure, you add the rule in the Network Security Group for the Jenkins master:
Install the Azure plugins
I ran into an issue I have a Jenkins Master in Azure