1

I have the following scenario.

I tried a simple pipeline job that clones my remote repo. It works fine when i set it to execute on master.

node {
   //stage 'Checkout'
     git([url: 'ssh://someusername@gerrit.mycompany.domain:29418/bla/bla.git', branch: 'mybranch'])
}

It uses the default git installation to run the command. I have configured git on a different pat for slave in jenkins configuration. when i try to run the same pipeline on a slave, it fails because it always tries to go the default git installation.

node ('myagent1'){
   //stage 'Checkout'
     git([url: 'ssh://someusername@gerrit.mycompany.domain:29418/bla/bla.git', branch: 'mybranch'])
}

The error is obvious:

Caused by: hudson.plugins.git.GitException: Error performing command: /jenkins-master-some-path/bin/git init /home/user/workspace/pipeline

/jenkins-master-some-path/bin/git is correct for master.

For normal jobs, we can choose one installation but can someone tell me if there is a way to use different git installation for pipeline on a slave.

tim_yates
  • 167,322
  • 27
  • 342
  • 338

2 Answers2

1

Ohhh I found a way. Instead of using git command, i used this "checkout" module. From pipeline job configuration, if you click on "pipeline Syntax", it takes you to another page. There you can generate groovy just by using the GUI.

1

Another solution, that will work with all the tools, is to configure specific tools installations path for your specific agent node.

Go to :

Jenkins > Manage Nodes > myagent1 > nodes properties > tools 

... and then select the tool that cannot be found on your agent (e.g. Git executable) and just fill there your executable path.

Pom12
  • 7,622
  • 5
  • 50
  • 69