Can I use git command in delivery pipeline if git is installed in different path on jenkins agent than on master

梦想与她 提交于 2021-02-07 10:20:10

问题


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.


回答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.




回答2:


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.



来源:https://stackoverflow.com/questions/38854180/can-i-use-git-command-in-delivery-pipeline-if-git-is-installed-in-different-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!