Setting up Freestyle Projects

Let's try and set up freestyle projects using Jenkins. You need to first ensure that you have Jenkins up and running, and that you are authenticated as the admin. To set up a freestyle project, follow these steps:

  1. Open the main dashboard to create a project using the New Item option on the left navigation menu.

If still available, you may also use the create new jobs prompt to create a project, as seen here:

Here's what the menu looks like:

The view above presents the various job types Jenkins supports. This chapter shall solely focus on Freestyle projects, but we will however look into more jobs and items as we progress.

  1. Enter the name as jenkins-python-run and select Freestyle project as highlighted in the following screenshot, and then select OK.

Jenkins should automatically take you to the project configuration view. All content can be quickly accessed through the tabs. Take a look at this screenshot:

We'll have a look at all the content step by step. For now, let's understand what the Source Code Management resource does. This checks out code from version control hosts. This means that if your code is hosted on GitHub or any other web-based repositories, you can add the repository details and Jenkins will clone it.

Feel free to use the quick tips displayed in the blue question mark icons, as they can be very resourceful and provide more clarification.

  1. Select Git and the following menu should drop down. This entails the information needed to clone a Git repository.
  1. Let's get the repository we are going to build from GitHub. From your browser, head to the following address https://github.com/TrainingByPackt/Beginning-Jenkins

From the repository, notice that we are on the master branch. Take a look at this screenshot:

  1. Select the Clone or download button and copy the link, as shown in the following screenshot:

This is the link Jenkins will use to clone the repository in order to run our tests.

  1. Back on our project configuration, add the repository link as follows:
For now, this is all we need to do to clone a public repository from GitHub. Private repositories need extra authentication, so be sure to provide credentials on the Credentials field. We will cover this in a later chapter.

Now, let's get back to examining what the rest of the tabs in the project configuration view do. The Build Triggers resource helps in automating builds. When setting up pipelines, some of the processes need to be automated in order to be effective. Some of these processes may include build and deploy steps:

When changes are pushed to GitHub, Jenkins should automatically run tests and build applications instead of developers triggering manual builds each time. More of this will be covered in the next section.

The Build Environment resource, as its name suggests, is involved with the environment–more precisely, the application environment. Credentials need to be set to, for example, access a server; a language-specific detail, such as Python virtual environments; and project management resources such as ticket tags:

Under the Build menu, you will find the drop-down with the following options:

This resource defines the actual steps we want to achieve, for example:

  • Do you want to run a script?
  • Do you want to run a command?
This step can be extended by installing plugins, and some of those steps might vary depending on the Jenkins version running and/or the installed plugins.

The Post-Build Actions are actions you want to do after a task is done. For instance, if you were running tests on the Build option, you could:

  • Send an email notification
  • Generate and send a report
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.133.228