Sunday, 13 November 2016

Jenkins - Setup Build Jobs


For this exercise, we will create a job in Jenkins which picks up a simple HelloWorld application, builds and runs the java program.
Step 1 − Go to the Jenkins dashboard and Click on New Item
Setup Build Jobs
Step 2 − In the next screen, enter the Item name, in this case we have named it Helloworld. Choose the ‘Freestyle project option’
Helloworld
Step 3 − The following screen will come up in which you can specify the details of the job.
Helloworld Config
Step 4 − We need to specify the location of files which need to be built. In this example, we will assume that a local git repository(E:\Program) has been setup which contains a ‘HelloWorld.java’ file. Hence scroll down and click on the Git option and enter the URL of the local git repository.
Note − If you repository if hosted on Github, you can also enter the url of that repository here. In addition to this, you would need to click on the Add button for the credentials to add a user name and password to the github repository so that the code can be picked up from the remote repository.
Git Repository
Step 5 − Now go to the Build section and click on Add build step → Execute Windows batch command
Execute Windows Batch Command
Step 6 − In the command window, enter the following commands and then click on the Save button.
Javac HelloWorld.java
Java HelloWorld
Save
Step 7 − Once saved, you can click on the Build Now option to see if you have successfully defined the job.
Build Now
Step 8 − Once the build is scheduled, it will run. The following Build history section shows that a build is in progress.
Build History
Step 9 − Once the build is completed, a status of the build will show if the build was successful or not. In our case, the following build has been executed successfully. Click on the #1 in the Build history to bring up the details of the build.
Details
Step 10 − Click on the Console Output link to see the details of the build
Console Output1Console Output2
Apart from the steps shown above there are just so many ways to create a build job, the options available are many, which what makes Jenkins such a fantastic continuous deployment tool.

No comments:

Post a Comment

Ansible: Roles

Use Ansible roles to orchestrate more complex configurations.Let's create a new directory named  nginx , which will be a Role. Then we&...