Jenkins Path to Git Windows Master/Linux Slave

Jenkins path to git Windows master / Linux slave

Ensuring "git" in the path of all slaves and master is one good way.

However Jenkins can have multiple installation of git (true for other tools such as jdk, groovy...)

You can configure this from http://server-url/configure

Sample Image

Click on "Add Git" and provide new git with different name and path

Sample Image

You can then "select which git to use" in the "jobs" configuration.

Sample Image

This approach has a positive side effect. It will allow you to use different git client versions (say for testing)

Jenkins Poll SCM (Git) on Windows master / Build on Linux slave

As requested, I'm posting my own answer to the general idea, for mixing Windows/Linux on Master Slaves when working with git. This solution will allow even to run the same job on multiple mix of Windows/Linux slaves as well as won't break Master polling scm:

Whatever you Jenkins Master platform is, configure the default git installation to point to a valid git for that platform. For example, c:\apps\git\bin\git.exe for Windows. and then configure the custom "Tool Locations" for each node. This way the master will be able to poll git to check for changes and trigger the job on a slave. The Slave will then be capable to clone the git code because it has its custom location for (Git) Default. Steps to configure properly:

  1. Manage Jenkins > Manage Nodes
  2. For each node having git location other than the one provided in the "Git installation", do:

    1. Open node configuration page (Configure icon)
    2. Check "Tool Locations" if not already checked
    3. Click "Add"
    4. Select "(Git) Default" on the dropdown
    5. Enter the path to the slave node git installation (e.g. /usr/local/bin/git)
    6. Save
  3. Repeat steps 2.1 to 2.5 for each Linux slave the job may run.

Node configuration for the linux slave node should look something like this:

slave node configuration

I believe the additional "git installations" are more suitable, as @Jayan mentioned, when you need to have multiple git installations or you need to run, for some reason, a specific version of git for select Jenkins jobs.

Git not in path during build step in jenkins

The OP created a Jenkins VM in the context of Bitnami Jenkins for Google Cloud Platform, you can check out the section "How to start with Git and Jenkins?"

As described below, that does not work well (the PATH does not include Git on bower operations)

Workaround, proposed by the OP:

Created another Jenkins VM, this time not using the Bitnami Jenkins.

It works out of the box.


Original answer.

Regarding bower, check bower issue 972

had to go into /bower/lib/core/resolvers/GitResolver.js and comment out the line that checks if Git is there to get this to work. It seems that the which module isn't working correctly for me.

Commented out line:

if (!hasGit) {
throw createError('git is not installed or not in the PATH', 'ENOGIT');
}
  • Bower: 1.7.7
  • Node: 5.9.0

More generally:

You need to make sure:

  • Jenkins global settings has a Git PATH defined
  • the slaves have a Git installed at that PATH

Example:

https://i.stack.imgur.com/8wO20.png

(Source: "Jenkins path to git Windows master / Linux slave")

That way, you don't depend on the PATH environment variable (on the master or the slaves), as Jenkins will complete it with the Git path defined.

Just in case the slave is executed with a different account (and different PATH), try (if your current PATH does include git) to make that path available to all users (for testing):

echo "PATH=$PATH" | sudo tee /etc/environment


Related Topics



Leave a reply



Submit