Configure Jenkins Tools for Kubernetes Pipeline Plugin

8/27/2019

I have a declarative build pipeline in Jenkins. The project is a multibranch project and uses the Jenkins Kubernetes Plugin to spawn build pods.

I ran into the problem, that the initial checkout of the branch fails. The job searches for git in the wrong path.

Git is is globally configured for Windows based Jenkins nodes, which leads to the following error:

Caused by: java.io.IOException: Cannot run program "C:\Program Files\Git\bin\git.exe" (in directory "/home/jenkins/workspace/P_mybuildpod-«id»"): error=2, No such file or directory

I can't change this because this will have impact on other projects.

I already tried to add another tool "linuxgit:/usr/bin/git" and configure it in the pipeline by tools { git 'linuxgit'}, but according to https://issues.jenkins-ci.org/browse/JENKINS-54334, this is currently not working.

Someone has similar experiences and maybe a good solution for that?

In the Jenkins Settings is an option to define a "Tools" section for pods. Therefore I need to inherit a global podTemplate. But I would prefer to prevent this (especially because I'm using a declarative approach).

-- Oliver Probst
git
jenkins
jenkins-pipeline
kubernetes

1 Answer

8/27/2019

I found a sufficient solution: I disabled the default checkout and do it manually in the pipeline.

    options { 
        skipDefaultCheckout(true)
    }
-- Oliver Probst
Source: StackOverflow