10

It's the first time I'm using Jenkins. I created a new folder with just one file and created a git repository in it. Then I set up Jenkins with that repository.

What I get now is this error:

ERROR: Checkout of Git remote 'path\hello' 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

I tried to start jenkins using this command:

C:\Users\userName\.jdks\zulu11.56.19-ca-jdk11.0.15-win_x64\bin\java.exe -jar jenkins.war  hudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true

But it didn't work. How can I set this "allow local checkout" to true?

Little Monkey
  • 5,395
  • 14
  • 45
  • 83

6 Answers6

7

Define properties using option -D: -Dhudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true

rootShiv
  • 1,375
  • 2
  • 6
  • 21
Axel
  • 86
  • 1
  • When I try: java -Dhudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true -jar jenkins.war, I get this exception: java.lang.ClassNotFoundException – Little Monkey May 23 '22 at 09:23
  • 1
    Ok, now it works. The property needs to be between quotes. -D"hudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true" – Little Monkey May 23 '22 at 10:53
  • It works great for me as-is: `-Dhudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true` – Max Cascone Jun 06 '22 at 20:09
  • I also had to use quotes `-D"hudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true"`. Jenkins 2.387.1 on Windows. – zett42 Mar 20 '23 at 14:27
  • For me it does not work at all. I have set the system property correctly and when I open the script console of jenkins and type `System.getProperty("hudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT")` and run it, I get `Result: true`. However, when I build, I still get the same error: `You can allow local checkouts anyway by setting the system property 'hudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT' to true.` So jenkins is broken. Using 2.387.3 – Jörg May 16 '23 at 16:08
  • Feature only exists in documentation and error message but not handled in the code: https://github.com/search?q=org%3Ajenkinsci%20hudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT&type=code – Jörg May 16 '23 at 16:14
  • https://issues.jenkins.io/browse/JENKINS-68571 – Jörg May 16 '23 at 16:39
  • Where to add this option in config file? On CentOS7, I tried to add /lib/systemd/system/jenkins.service and restart jenkins service, but still get this error. – Nick Jun 20 '23 at 05:09
  • for some lazy monkey like me, using services, add this to the jenkins.xml solved the problem. ```-Xrs -Xmx4g -Dhudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "D:\Soft\Jenkins\jenkins.war" --httpPort=8080 --webroot="%LocalAppData%\Jenkins\war" ``` PS: restart needed. – QuantumBlindVimTaoist Jun 25 '23 at 06:59
4

I have faced the same issue the solution was:

-Dhudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true needs to be BEFORE -jar jenkins.war in the command line call.

The solution is provided from the below recourse:

https://community.jenkins.io/t/checkout-of-git-remote-aborted-because-it-references-a-local-directory/4110

Yaser Ananbeh
  • 134
  • 1
  • 2
1

In my case I am running Jenkins on WSL2 (Ubuntu), I edited the file "jenkins" located at /etc/default, added the line:

JAVA_ARGS="-Dhudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true"

right below an existing line, like so:

# Allow graphs etc. to work even when an X server is present
JAVA_ARGS="-Djava.awt.headless=true"
JAVA_ARGS="-Dhudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true"

After saving the file, did a "service jenkins restart" and it worked for me, now whenever Jenkins is started I don't have to specify the option manually.

tariq101
  • 127
  • 2
  • 6
1

For Ubuntu edit config:

sudo gedit /lib/systemd/system/jenkins.service

Add line:

Environment="JAVA_OPTS=-Dhudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true"

Restsart service:

service jenkins restart
systemctl daemon-reload

Check config:

systemctl cat jenkins
profimedica
  • 2,716
  • 31
  • 41
0

For RedHat/CentOS, edit config file at: /etc/sysconfig/jenkins
Find: JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true"
Add below:
JENKINS_JAVA_OPTIONS="-Dhudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true"
Then restart: sudo systemctl restart jenkins

EmRa
  • 11
  • 3
0

If you're using macOS and installed Jenkins-LTS using Homebrew, you only need to edit the /usr/local/opt/jenkins-lts/homebrew.mxcl.jenkins-lts.plist file and add <string>-Dhudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true</string> before <string>-jar</string>. Save the file and run brew services restart jenkins-lts. The complete contents of this file after the edits:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>homebrew.mxcl.jenkins-lts</string>
    <key>LimitLoadToSessionType</key>
    <array>
        <string>Aqua</string>
        <string>Background</string>
        <string>LoginWindow</string>
        <string>StandardIO</string>
        <string>System</string>
    </array>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/opt/openjdk@17/bin/java</string>
        <string>-Dmail.smtp.starttls.enable=true</string>
        <string>-Dhudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true</string>
        <string>-jar</string>
        <string>/usr/local/opt/jenkins-lts/libexec/jenkins.war</string>
        <string>--httpListenAddress=127.0.0.1</string>
        <string>--httpPort=8080</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>
Staccato
  • 614
  • 1
  • 7
  • 17