Jenkins - Active Choice Plugin not found script after restart jenkins

Hi everyone,

I have a Jenkins pipeline that uses the Active Choices plugin, where parameters are read from a shell script file located directly on the Jenkins server.

  • The script path is called using an absolute path (e.g. /Scripts/ListParam.sh)

  • File exists and permissions are correct

  • It works normally under regular conditions

Issue:
When the Jenkins server VM is shut down and restarted, the Jenkins service is started automatically by systemd. At this moment, I get the following error:

Caused: java.io.IOException: Cannot run program "/Scripts/ListParam.sh": 
error=2, No such file or directory

When I log in to the server and check:

  • The file /Scripts/ListParam.sh exists

  • Permissions are correct

  • /bin/bash is available

After manually restarting the Jenkins service (systemctl restart jenkins), everything works fine again and the Active Choice parameter loads correctly.

Question:
Has anyone experienced this issue?
How can I prevent this from happening after a VM reboot (so that Jenkins can run the Active Choices script correctly on the first auto-start without requiring a manual service restart)?

Hello and welcome to this community, @RedDG! :waving_hand:

It looks like the problem is that Jenkins is coming up before your /Scripts directory is actually available after a reboot. :thinking:
This often happens if /Scripts is on a separate mount (NFS, network share, or another disk) that systemd hasn’t finished mounting yet when Jenkins starts.

A couple of ways you could address this:

  1. Tell systemd to wait for the mount
    You can update the Jenkins service unit (often found at /usr/lib/systemd/system/jenkins.service or /etc/systemd/system/jenkins.service) and add a line like this under [Unit]:
RequiresMountsFor=/Scripts

That way, systemd makes sure /Scripts is mounted before Jenkins tries to start. :person_shrugging:

After editing, run:

sudo systemctl daemon-reload
sudo systemctl enable jenkins
  1. If /Scripts isn’t a mount, but something else sets it up at boot
    In that case, you could add an After=... dependency in the service file so Jenkins waits for whatever process is responsible for creating it.

In short: the root cause may be that Jenkins is starting a little too early. Adding the right dependency in the systemd unit file should make sure /Scripts is ready before Jenkins launches, and avoid the error after reboot. :crossed_fingers: