jenkins_jobs/pre-receive.hook broken by design during some migrations due to not cleaning up $JENKINS_JOBS_TEST_DIR
Originally created by @intrigeri on #14932 (Redmine)
It’s not the first time this happens, and once again it took me a while to figure out a workaround, so this time I’m going to report a bug.
E.g. I see:
remote: jenkins_jobs.errors.JenkinsJobsException: Failed to find suitable template named 'reproducibly_build_Tails_ISO_{realname}'
remote: FAIL, rejecting your push. Please fix before pushing again.
To jenkins.sib:jenkins-jobs.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'gitolite@jenkins.sib:jenkins-jobs.git'
… while there is no instance of
reproducibly_build_Tails_ISO_{realname}
in my jenkins-jobs.git
.
Emptying $JENKINS_JOBS_TEST_DIR
fixes this problem.
The reason for the breakage is that $JENKINS_JOBS_TEST_DIR
still has
old files, that got removed since, that reference a template which got
renamed. I think this hook should create a temporary directory with
mktemp, extract there, test it, and clean it up via trap
. This seems
pretty easy to do. Or is there a reason why we should always use the
same directory with cruft accumulating?
I’ll let you classify this ticket under the right SponsorX deliverable for, and prioritize it as you wish. As a user of this system, I’d like to see this fixed before the next similar job template migration that would trigger this problem again.