Home > Back-end >  Why does Jenkins creates a subfolder within the workspace@script folder to checkout git code instead
Why does Jenkins creates a subfolder within the workspace@script folder to checkout git code instead

Time:02-17

This happened after I updated some plugins and added 'blue ocean' to our Jenkins.

Every job we have is using a JenkinsFile to build and package our applications.

But we are loading some groovy files within our git from the workspace@script folder, so this is what I did :

script {
    slack = load WORKSPACE   "@script/jenkins/libs/toto.groovy"
}

But now I have to do this to have the right folder :

script {
    // Locate the jenkins folder
    // This is done because there is a new sub-folder (like : 17a4ba1ed1ce777b18c5...)
    // that appeared out of nowhere (update -> security ??)
    git_jenkins_folder = sh (
        script: "find "   WORKSPACE   "@script -type d -name 'jenkins' -printf '%T@ %Tc %p\n' | sort -rn | head -1 | cut -d' ' -f9",
        returnStdout: true
    ).trim()
    // Load the groovy methods in groovy files
    slack = load git_jenkins_folder   "/libs/toto.groovy"
}

And of course, I had to remove previously checked out code from the workspace@script folder for this to work.

Why did this happened all of a sudden ? I was thinking of a security update maybe ?

What if this number changes in the future and a new folder appear ??

This is really weird IMHO but maybe I missed something. If someone out there has the answer I'll gladly read it :)

EDIT :

Thanks to @1141514admin, this was done to address those issues with the 'Pipeline: Groovy' plugin :

EDIT 2 :

Added retrieval of the last modified folder in case this folder name changes in the future.

CodePudding user response:

I just noticed this new behavior in my builds today as well. I had updated some plugins earlier. I found that on my server it's the 'Pipeline: Groovy' plugin, version 2656.vf7a_e7b_75a_457 that's causing these new subfolders with lengthy randomized names which contained the cloned repo files. The problem for me was it was resulting in builds failing, causing file paths to exceed 260 characters which is a default limit in Windows. I downgraded the 'Pipeline: Groovy' plugin to version 2648.va9433432b33c and after restarting the Jenkins service I was no longer seeing these new random-named subfolders in the workspace build folders.

  • Related