Linking Jenkins to a Local Git Repository

I wanted to try creating a CI (continuous integration) pipeline using Jenkins at home for fun 🙂

I launched IntelliJ IDEA by jetbrains and created an empty test project. Then I added this project to Git. In case you don’t know how, below is how you can create a Git repository for you project in IntelliJ IDEA (Community 2017.1.2).

intellij-idea-create-git-repository

Once the Git repository has been successfully created you should see a .git folder as below (You may need to enable display of hidden folders).

.git folder

Now, launch Jenkins (by default it should launch on http://localhost:8080/).

Now click on New Item, select “Freestyle project” and type a name for it, click OK.

jenkins new item

 

jenkins freestyle project

Go to Source Code Management tab and select Git

jenkins source code management tab

The critical part is what you enter here as the “Repository URL”. The correct value should start with file://// for a local repository which is created on your PCs local file system.

For a test project which was created under “Users/serdarosmanonur/IdeaProjects/JavaProject” the Repository URL should be entered as “file:////Users/serdarosmanonur/IdeaProjects/JavaProject”.

Now save this configuration, go to “Jenkins” dashboard (http://localhost:8080/) and click your projects name on the right.

jenkins dashboard

Click “Build Now” on the left. You should see the build success entry on the Build History area below the Build Now button.

jenkins build project

You have successfully linked Jenkins to your local Git repository and completed your first build.

Hope this helps.
Good Luck,
Serdar

Serdar Osman Onur
I love coding web stuff, learning/applying new technologies and techniques to create things on the internet since 2004. AboutMe G+ twitter
Serdar Osman Onur

@serdarosmanonur

hard work, determination, dedication, patience, consistency, faith
"We forge our bodies in the fire of our will" - Enter the Dragon - 1973 - 3 days ago
Serdar Osman Onur