dockerjenkinsjenkins-pipeline

Jenkins Pipeline Error: "Selected Git installation does not exist."


I'm setting up a Jenkins pipeline that fetches the script from the SCM. However, I'm encountering an error during the pipeline execution. The pipeline is configured to run inside a Docker container with Jenkins and Git installed. Here are the details:

Obtained Jenkinsfile from git https://github.com/Sidharth-Singh10/testscore
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/trail2
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
Selected Git installation does not exist. Using Default
The recommended git tool is: NONE
No credentials specified
 > git rev-parse --resolve-git-dir /var/jenkins_home/workspace/trail2/.git # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/Sidharth-Singh10/testscore # timeout=10
Fetching upstream changes from https://github.com/Sidharth-Singh10/testscore
 > git --version # timeout=10
 > git --version # 'git version 2.39.2'
 > git fetch --tags --force --progress -- https://github.com/Sidharth-Singh10/testscore +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git rev-parse refs/remotes/origin/main^{commit} # timeout=10
Checking out Revision 1f42c4a68d6dce1797bc27aaf709e61118dd74b3 (refs/remotes/origin/main)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 1f42c4a68d6dce1797bc27aaf709e61118dd74b3 # timeout=10
Commit message: "Create Jenkinsfile"
First time build. Skipping changelog.

Jenkinsfile:

pipeline {
    agent any

    environment {
        DOCKER_IMAGE = 'sidharthsingh7/ss_backend'
        DOCKER_TAG = "0.0.1.RELEASE"
    }

    stages {
        stage('Checkout') {
            steps {
                git scm
            }
        }

        stage('Build') {
            steps {
                script {
                    sh 'docker build -t $DOCKER_IMAGE:$DOCKER_TAG .'
                }
            }
        }

        stage('Test') {
            steps {
                script {
                    sh 'docker run --rm $DOCKER_IMAGE:$DOCKER_TAG npm test'
                }
            }
        }

        stage('Push to Docker Hub') {
            steps {
                script {
                    sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin'
                    sh 'docker push $DOCKER_IMAGE:$DOCKER_TAG'
                }
            }
        }
    }
}

Environment:

Jenkins is running in a Docker container.
The Git plugin is installed and up to date.
Git version is 2.39.2.

Problem: The pipeline fails with the message: "Selected Git installation does not exist. Using Default. The recommended git tool is: NONE."

Questions:

Why is Jenkins unable to recognize the Git installation?
How can I resolve the issue and ensure Jenkins uses the installed Git version?

Steps I've Tried:

Ensured the Git plugin is installed.
Verified Git is installed and accessible within the Docker container (git --version returns 2.39.2).
Checked Jenkins configuration for Git installation paths.

Any help or guidance would be greatly appreciated!

Thank you.


Solution

  • The log Selected Git installation does not exist. Using Default. The recommended git tool is: NONE. is not an error is just a warning.

    A proof is after that message, execution continues and other git commands are performed without error:

    enter image description here

    If git doesn't exist, the log would be:

    enter image description here

    git verify

    To verify if git exist, you could list the cloned files after clone and before build with command ls -la:

    pipeline {
        agent any
    
        environment {
            DOCKER_IMAGE = 'sidharthsingh7/ss_backend'
            DOCKER_TAG = "0.0.1.RELEASE"
        }
    
        stages {
            stage('Checkout') {
                steps {
                    git scm
                }
            }
    
            stage('Validate') {
                steps {
                    script {
                        sh 'ls -la'
                    }
                }
            }
    

    If you see your folder and files in the log, git is already installed and working.

    Any other error will be for other reasons, no git

    Fix the warning

    With the admin credentials, go to administration and select the git binary location

    enter image description here