Create a Jenkins ProjectApril 4, 2016
In this post we’ll create a Jenkins project on our brand new shiny server that we just deployed. The project we create will be very simple but should show off the possibilities of using a Jenkins server to test your code.
To get started login to your Jenkins server at the http://jenkinsservername:8080 port and then click the “New Item” link. From there give your new project a name. In this example our project is a Freestyle project which will let us throw code right into the project and run it on the Jenkins server or subsequent Jenkins Nodes.
Give the Project a name and a description. We’re seasoned programers and we always put great comments in our code right? Let’s be sure to add great project names and descriptions to our projects in Jenkins too shall we?
We can scroll down until we get to the Build section and then click the “Add build step.” Select the “Execute shell” option. This will mean that whatever code we decide to run will be run from a shell prompt, and in this case will be run directly on the Jenkins server.
Now in the command window we’ll put our code to run. In this example we’re just going to write some text. When you’re done click “Save.”
Now we’re back at the Jenkins main screen where we see the new project we created. Notice under the S (S for status) column the status is grey which means its never been run. Also notice that under the W (W for Weather) column, we have bright sunshine. Weather is the aggregated status of multiple builds. Since there have been no failed builds yet, everything is sunny!
Click the clock icon on the right side of the project. This will schedule the build.
Click on the name of the project and we’ll see the build history in the left hand side of the screen. This will show any builds for this project. Click on the build that we just ran. (Click #1)
From there we can select the “Console Output” to show what the command shell ran and any results. You can see that the build finished with a result of “SUCCESS.” We’re amazing coders so this should not be a surprise to us.
Let’s see what were to happen if we had a failure. Go back in and configure the same project but this time let’s make a typo in the shell command like the one below. (Hint: “Checko” isn’t a valid shell command in Linux)
Run the project again and we see the output as “FAILURE.”
Now on the main screen we’ll see that the status shows a red ball. This means that the last run was a failure. In addition, the Weather shows that it’s cloudy which isn’t good.Go back and fix your code in Jenkins and run the build again. Once the build is successful again we’ll get our blue status ball, but the weather won’t be bright and sunny. It will be “partly” sunny.
Run the build a few more times successfully and the weather will go back to sunny.