Requirements

Jenkins board overview

As can you see, the Jenkins console is clean and very easy to understand.

(1) – There is the Main Menu on the left hand site which contains the most frequently used options:

New Item – Creates new job or project.

People – Displays People board. People management is in Manage Jenkins -> Manage Users menu.

Build History

Manage Jenkins – This is Jenkins heart. There is a lot of usefull optrons and preferenes. In this tutorial I show you how to:

secure Jenkins

add new user

install and update plugins.

working with environment variables

My Views – This view displays all the jobs that the current user has an access to.

Credentials – Manage credentials view.

(2,3) – The job list. Displays all jobs the current user has an access to. Jobs can be grouped into tabs (3).

(4) – Displays the current state of executors. There is two executors by default. It means that there is only two jobs allowed to execute in the same time. Another jobs wait in build queue (5).

(6) – Search bar – It’s easy way to find job, user and some other options.

(7) – Schedule a build

(8) – Breadcrumbs – Navigation current place.

Basic Jenkins security

There is good practice to secure jenkins. Follow this part of tutorial to add basic Jankins security using internal credential store.

Open the Jenkins console and go to Manage Jenkins -> Configure Global Security. Enable security, choose Jenkins’ own user database and select Logged-in users can do anything. Click save and singup the first user: jenkins with password welcome1.

Installing Jenkins extensions (plugins)

To install Jenkins plugin just go to Manage Jenkins-> Manage Plugins. Select plugin you want and click Install. In the next part I show you Workspace Cleanup Plugin installation.

The First job

The result of this part is a job that creates two files in the workspace. Here is a script to do this i shell:

FirstJob-CreateFile.sh

Shell

1

2

echo"Some script.">>script1.txt

echo"Some other script.">>script2.txt

To cerate the “FirstJob-CreateFile” job go to Home Page, click New Item, enter the item name and choose Freestyle project. On the job cofiguration screen add Execute shell build step, paste your script as Command and click Save.

Running a job

Go to Home Page and open FirstJob-CreateFile project (1). Click Build Now (2) and refresh page. Click the #1 build instance from the Build History panel (3) and go to Console Output to see execution result (4).

Project workspace

Each Jenkins project contains its own workspace. In the above example it’s:

Shell

1

/var/lib/jenkins/jobs/FirstJob-CreateFile/workspace

The workspace is not cleared between the builds by default. So every next build instance is executing in the same workspace.

To see this behaviour open FirstJob-CreateFile, click Workspace (1) and open script1.txt file (2). As you can see there is one text line in the file (3). Run the job again and open script1.txt file. There is another line in the file (4), because:

the workspace was not cleared

shell build script contains >> operator which appends text to a file.

FirstJob-CreateFile.sh

Shell

1

2

echo"Some script.">>script1.txt

echo"Some other script.">>script2.txt

Clearing the project workspace

Manually

It’s possible to manually clear the project workspace. Open workspace and click Wipe Out Current Workspace.

Shell script

One of the way to clear project workspace on every build is to modify the shell script: