Checkout step in Pipeline failing because it's referrences to the local directory

Hi,

I have a pipeline with the checkout step as below… It’s failing with the very clear error that the remote git is local repository. Our git is setup in that way we have access only through the server to that repository (/git-repo/merp.git). So how to bypass my below error. I want the checkout step to work for the local repository. I have ran the below command in the script console in the jenkins UI. But still i’m getting the error.


Command ran in the script console:
System.setProperty(“hudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT”, “true”)

println(System.getProperty(“hudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT”))

The result i got is true. But still getting the same error



Error Message:
ERROR: Checkout of Git remote ‘/git-repo/merp.git’ aborted because it references a local directory, which may be insecure. You can allow local checkouts anyway by setting the system property ‘hudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT’ to true.
Finished: FAILURE



Here is my checkout step:
checkout changelog: true, poll: true, scm: [class: 'GitSCM', branches: [[name: "origin/{params.branch}"]],
doGenerateSubmoduleConfigurations: false, extensions: [[$class: ‘ChangelogToBranch’,
options: [compareRemote: ‘origin’, compareTarget: ‘qa’]]], submoduleCfg: , userRemoteConfigs: [[credentialsId: ‘**************’, url: ‘/git-repo/merp.git’]]]


I have seen some suggestions to add the above property in the /etc/sysconfig/jenkins file. but i don’t see any jenkins file under the “/etc/sysconfig” directory.

Note: I installed jenkins using the yum package and my version of jenkins is 2.426.1

Please let me know if anyone faced this issue and what are the steps you followed to resolve it.

Thanks,
Prudhvi M.

I would recommend checking out this page for information on setting system properties for services managed by systemd. It has information on setting things in the sysconfig.

Hi slide_o_mix,

Thanks for the link. I have tried those recommendations and edited the jenkins file with the systemctl option and set the environment system property and then restarted the jenkins.

I reran the pipeline and still throwing the same error. More inputs and responses will be appreciated

Thanks,
Prudhvi M.

Can you share your sysconfig file?

Attached the jenkins.service file. please note that when i’m doing cat to the jenkins.service file it’s not showing the property i added. But when i’m running the systemctl cat jenkins command it’s listing my property in the end of the file like below.


/etc/systemd/system/jenkins.service.d/override.conf

[service]
Environment=“JAVA_OPTS=-Dhudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true”


Please let me know if you need any further info from my side.

jenkins.log (5.3 KB)

Can you try [Service] (with a capital S)?

2 Likes

I think that’s exactly right. Mine looks like this:

[Unit]
Description=Jenkins ubuntu-22-a

[Service]
# Arguments for the Jenkins JVM
Environment="JAVA_OPTS=-XX:+AlwaysPreTouch -Djava.awt.headless=true"
# Set the context path for use as https://home.markwaite.net/jenkins/
Environment="JENKINS_PREFIX=/jenkins"

Thank you so much @slide_o_mix, changing the [service] to [Service] worked.

@MarkEWaite Thanks for your response