Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-49569

Pipeline archives artifacts with weird untraceable folder name

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • blueocean-plugin
    • None

      Thanks for Blue Ocean plugin, it builds and archives artifacts in "${JENKINS_HOME}/jobs/${PROJ_NAME}/branches/${BRANCH_NAME}".

      But when a branch name contains "_(underscore)" or ".(dot)", it causes "${hyphened branch name}.${6 chars hash}" which I cannot utilize to deploy.

      Why does it happen? What's the best practice to use branch archives?

          [JENKINS-49569] Pipeline archives artifacts with weird untraceable folder name

          James Dumay added a comment -

          It uses double encoding of the URL to escape non-URL safe characters as these characters may not be compatible with all filesystems.

          The best practice here would be to create an archive (zip/tar/etc) and publish it directly to an artifact repository like SonaType Nexus or JFrog Artifactory.

          If you just want to use plain old Jenkins, I'd use a archive (zip/tar/etc) with a well known name.

          James Dumay added a comment - It uses double encoding of the URL to escape non-URL safe characters as these characters may not be compatible with all filesystems. The best practice here would be to create an archive (zip/tar/etc) and publish it directly to an artifact repository like SonaType Nexus or JFrog Artifactory. If you just want to use plain old Jenkins, I'd use a archive (zip/tar/etc) with a well known name.

          pigloves you added a comment -

          jamesdumay Thank you for the explanation. Thing is, even if I name a plain branch name like "feature-1" and push commits several times, the branch names will be "feature-1_2" and "feature-1_3", which cause the path transformation, maybe because the "_(underscore)"s. It seems like I don't have the latter option to choose.

          pigloves you added a comment - jamesdumay Thank you for the explanation. Thing is, even if I name a plain branch name like "feature-1" and push commits several times, the branch names will be "feature-1_2" and "feature-1_3", which cause the path transformation, maybe because the "_(underscore)"s. It seems like I don't have the latter option to choose.

          pigloves you added a comment -

          jamesdumay Please, it is not solved. Jenkinsfile has `archiveArtifacts` syntax. When we archive something, we want to use it. I need a way to trace the path like `Fix-2.27ittn`. 

          pigloves you added a comment - jamesdumay  Please, it is not solved. Jenkinsfile has `archiveArtifacts` syntax. When we archive something, we want to use it. I need a way to trace the path like `Fix-2.27ittn`. 

          pigloves you added a comment -

          In a company I'm working for, there is no SonaType-like repository. If there is "archiveArtifacts" function, please tell me how I can use the artifacts. At least please tell me what's the transformed path name so that I can use the artifacts.

          pigloves you added a comment - In a company I'm working for, there is no SonaType-like repository. If there is "archiveArtifacts" function, please tell me how I can use the artifacts. At least please tell me what's the transformed path name so that I can use the artifacts.

          Liam added a comment -

          I think this is the same issue I am getting. We changed the standard jenkins artifact publisher to use sftp as we have a lot of compile output and sftp is much quicker. 
           
          I have a branch called CDU-009_hi_john and am running a Jenkins multibranch pipeline build. My sftp needs to cd to the directory that will contain the outputs and that is failing as the directory does not exist. After investigation I see that jenkins has created the following directory:

          /var/lib/jenkins/jobs/CDM-Project/jobs/CDM-MultiBranch-Pipeline/branches/CDU-009-hi-john.2ujcja/builds/10/archive

          Jenkins changes the underscores to hyphens and adds a weird 6 character string to the end. Looking at all my other pipelines this seems to be consistent behaviour, but is only an issue on the pipelines that I want to use sftp (larger output to return).

          I wondered if there was a jenkins environment variable that might tell me where Jenkins is putting stuff but have listed all the obvious one:

          {{{}}}

          10:16:18 echo jenkinsHome /var/lib/jenkins 
          10:16:18 echo jobName /var/lib/jenkins/jobs/CDM-Project/CDM-MultiBranch-Pipeline/CDU-009_hi_john/ 
          10:16:18 echo jobBaseName CDU-009_hi_john 
          10:16:18 echo jobUrl http://pthdbb01.21csw.com.au:8080/job/CDM-Project/job/CDM-MultiBranch-Pipeline/job/CDU-009_hi_john/ 10:16:18 echo branchName CDU-009_hi_john

          {{ }}
          Of course, if I use hyphens in the branch name I have no problem. So I can make that a naming condition, but don't want to be so restrictive.

          Liam added a comment - I think this is the same issue I am getting. We changed the standard jenkins artifact publisher to use sftp as we have a lot of compile output and sftp is much quicker.    I have a branch called CDU-009_hi_john and am running a Jenkins multibranch pipeline build. My sftp needs to cd to the directory that will contain the outputs and that is failing as the directory does not exist. After investigation I see that jenkins has created the following directory: /var/lib/jenkins/jobs/CDM-Project/jobs/CDM-MultiBranch-Pipeline/branches/ CDU-009-hi-john.2ujcja /builds/10/archive Jenkins changes the underscores to hyphens and adds a weird 6 character string to the end. Looking at all my other pipelines this seems to be consistent behaviour, but is only an issue on the pipelines that I want to use sftp (larger output to return). I wondered if there was a jenkins environment variable that might tell me where Jenkins is putting stuff but have listed all the obvious one: {{{ } }} 10:16:18 echo jenkinsHome / var /lib/jenkins 10:16:18 echo jobName / var /lib/jenkins/jobs/CDM-Project/CDM-MultiBranch-Pipeline/CDU-009_hi_john/ 10:16:18 echo jobBaseName CDU-009_hi_john 10:16:18 echo jobUrl http: //pthdbb01.21csw.com.au:8080/job/CDM-Project/job/CDM-MultiBranch-Pipeline/job/CDU-009_hi_john/ 10:16:18 echo branchName CDU-009_hi_john {{   }} Of course, if I use hyphens in the branch name I have no problem. So I can make that a naming condition, but don't want to be so restrictive.

            Unassigned Unassigned
            piglovesyou pigloves you
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: