I try to set up the system property ‘hudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT’ to true. I am doing it in Script Console, and getting response True. But still can not work with my local git. How to make it really working?
Hello @Jacck and welcome to this community.
As far as I know, to enable Jenkins to use a local Git repository, you need to set (as you did) the system property hudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT
to true
and make sure that Jenkins has the necessary permissions to access the local repository.
Here are some steps that might help you to achieve this:
- You can set the system property in the Jenkins Script Console as you did:
System.setProperty('hudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT', 'true')
- In your Jenkins job configuration, set the repository URL to the local path of your Git repository. For example, if your repository is located at
/path/to/your/repo
, set the repository URL tofile:///path/to/your/repo
. - Make sure that the Jenkins user has read and write permissions to the local Git repository directory.
- Sometimes, changes to system properties require a Jenkins restart to take effect.
Restart Jenkins to ensure the property is applied.
Here is an untested example of how to configure the repository URL in a Jenkins pipeline:
pipeline {
agent any
stages {
stage('Checkout') {
steps {
git url: 'file:///path/to/your/repo', branch: 'main'
}
}
stage('Build') {
steps {
// Your build steps here
}
}
}
}
Setting a system property via script console will not change the value. The reason is that the system property is evaluated once at Jenkins startup. You can set the property as a command line parameter to the JVM of Jenkins (java -Dhudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true -jar jenkins.war ...
)
But you can still modify the behaviour of the git plugin by running
hudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true
in the script console.