Running job on local jenkins with local repository - jenkins

I have Selenium project and i want to run my job on local Jenkins 2.176.1 from local repository (using path to my project folder on disc).
Do You know where's that option? I remember that I use this option few months ago, but now I can't find box for path to files on disc.
Now I only see git/subversion option.
[]

Linking-jenkins-local-git-repository.
Go to Source Code Management tab and select Git
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 “/usr/local/projects/reporting-servicet” the Repository URL should be entered as “file:////usr/local/projects/reporting-service”.
Now save this configuration, go to “Jenkins” dashboard (http://localhost:8080/) and click your projects name on the right

#Sunny Sharma's answer works well for a local git repository. I setup a Multibranch Pipeline Project, added the following into Branch Sources > Git > Project Repository
file:///<path-to-local-git-repository>
or simply w/o file:///
<path-to-local-git-repository>
Where file:/// or file://// both are working for *nix style forward slash path. Even though you're using a local git repository, any changes you made needed to be committed locally first in order to let Jenkins check out and pick them up. Validated on Jenkins 2.263.4.

Related

Jenkins slave job with two git repos

I'm trying to setup master/slave on two osx machines, while using only slave for build.
Have one main git repo for the project but few additional files are kept in separate git repository. After adding two git repositories noticed after checkout it's creating two project directories under workspace and one has "#2" in the name.
That makes a problem with copying/accessing files between two repositories using $WORKSPACE variable as directory "project_name#2" is not logically part or $WORKSPACE (getting file not found error). And also cannot know which repo will be in which directory with every new build.
And more confusing sometimes it even pulls one repo to the master machine even though I've set that the build executes only on slave.
I'd appreciate any advice or suggestion?
If you're using the GIT plugin you can use advance cloning settings and specify a sub folder to clone to. make sure to clone to different folders under your workspace and then you can access both. I'm doing that in some of my projects and it works like a charm.
Use : https://wiki.jenkins-ci.org/display/JENKINS/Multiple+SCMs+Plugin
Good luck!

How do I clone a project to make a second project

My first project is a rails app written in Cloud9 and pushed to bit bucket and heroku in production.
How do I make an exact clone of this project so that I can rename it and begin working on a second project?
As per this tutorial you should:
Navigate to the repository in Bitbucket.
Click the Clone button.
Copy the clone command (either the SSH format or the HTTPS).
If you are using the SSH protocol, ensure sure your public key is in Bitbucket and loaded on the local system to which you are cloning.
Launch a terminal window.
Change to the local directory where you want to clone your repository.
Paste the command you copied from Bitbucket, for example:
$ git clone ssh://git#bitbucket.example.com:7999/PROJ/repo.git

How to show git diff in Jenkins

I have a build job in Jenkins, which is based on a git project.
Looking at the changes page for each build, I can see the commits that are new to this version, who contributed them, and the list of files modified.
What I'm missing is the option to see the actual diff - what lines of code were changed.
How can this be achieved?
I'm using a local git repo hosted on the same PC as the jenkins server
You can use Last Changes Plugin to accomplish that.
Just install it and make sure to choose from Post-build Actions drop down menu the option Publish Last Changes.

how to make jenkins use an already checked out codebase?

I am just starting with Jenkins 1.487 and wanted to integrate Jenkins in my Ant project. But while configuring it, I can't find any way to make Jenkins re-use an already checked out codebase, instead of downloading a fresh copy relative to its workspace root. Is there a way to do that ?
I tried to specify a custom workspace manually (where my codebase was already checked out), and clicked on 'Build now'. The result was that it wiped out my current checked out code saying
"Checking out a fresh workspace because there's no workspace at /home/daud/Work
Cleaning local Directory ."
Not even a warning..
If you really want to build from an existing checkout somewhere on the file system, then do not use "Source Code Management" section of Jenkins. Leave it as "none"
Go straight to the "Build" section
Click "Add Build Step"
Select Invoke Ant"
Click Advanced
And under "Build File", provide a full path to the ant build file on your file system. You would have to include the drive letter (if on Windows) or a leading / (if on Linux) to break from the Workspace (by default, this path is relative to Workspace). Or use a lot of ../../../.. if needed.
But like others have said, this is not the way a CI system is supposed to be used
The idea behind Jenkins and CI is that it works on a fresh copy of the codebase. Every build done by Jenkins should not depend on any external preconditions and it should be reproducible.
You might want to try using the Clone Workspace SCM Plugin for Jenkins. It will allow you to zip up the workspace from one job and use it to create the workspace for another one. I've used this for downstream jobs that need to act on the work from a previous job.
This is also helpful if you're using something like Git for source control and want to avoid a second Git clone (or SVN checkout). Furthermore, you can limit the content of zip file that is used to recreate the workspace, for example to avoid carrying unnecesary files (e.g. the .git or .svn directories) downstream.

Where is the Jenkins working directory located?

Situation:
I installed Jenkins on my vserver and setup a "freestyle pipeline". I connected it via webhook push to my github which works (when I push to the repository, a new build job is started in jenkins).
Problem:
I can't seem to find the working directory where the git pull is executed in. I already searched for answers and many people say $JENKINS_HOME, but echo $JENKINS_HOMEreturns a blank line for me. Did I do anything wrong or where is my project then? Also, can I set the path to where the repository is pulled to a custom path (say /root/myprojectname)?
EDIT:
I can see the workspace in Jenkins webuserinterface but I can't find the corresponding folder on the vservers drive.
Did you check in /var/lib/jenkins. By default the jenkins home directory lies there as well in case of linux servers. It should also show you the home directory by browsing Manage Jenkins--> Configure System

Resources