-
Bug
-
Resolution: Unresolved
-
Minor
-
None
# PROBLEM
i'm using nixos-23.11 with https://search.nixos.org/options?channel=23.11&from=0&size=50&sort=relevance&type=packages&query=services.jenkins
and using a "Multikonfiguration project" toolchain I always got this error message:
process apparently never started in /var/lib/jenkins/workspace/klick_Jenkinsfile-test@tmp/durable-e8bf8417
(running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)
Using this Jenkinsfile
pipeline { agent any stages { stage('Build') { steps { echo 'Building..' sh 'ls' sh 'nix-shell --command "just build"' archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true } } stage('Test') { steps { echo 'Testing..' sh 'nix-shell --command "just test"' } } stage('Check fmt') { steps { echo 'Checking fmt..' sh 'nix-shell --command "cargo fmt --check"' sh 'nix-shell --command "cd frontend; cargo fmt --check"' } } stage('Deploy') { steps { echo 'Deploying....' } } } }
And I've added the argument:
-Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true
Into the systemd service using a nixpkgs clone with a hack on the service file directly but it did not provide more helpful output to the problem.
However, keeping reading the other issues here I discoverd someone mentioning an empty PATH variable being the cause. Indeed this also is the problem on NixOS.
# SOLUTION
All you have to do is to add this to the Jekinsfile:
environment {
PATH="/run/current-system/sw/bin"
}
And the complete file looks like this then:
pipeline { agent any environment { PATH="/run/current-system/sw/bin" } stages { stage('Build') { steps { echo 'Building..' sh 'ls' sh 'nix-shell --command "just build"' archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true } } stage('Test') { steps { echo 'Testing..' sh 'nix-shell --command "just test"' } } stage('Check fmt') { steps { echo 'Checking fmt..' sh 'nix-shell --command "cargo fmt --check"' sh 'nix-shell --command "cd frontend; cargo fmt --check"' } } stage('Deploy') { steps { echo 'Deploying....' } } } }
A side note:
The "Free Style" Softwareproject toolchain worked without such PATH hacks. Duno why, maybe the shell is different. ALSO setting the shell interpreter command in the system settings of jenkins did not have an effect. I tried /bin/sh, /run/current-system/sw/bin/bash and /run/current-system/sw/bin/sh