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

Forward slash in branch name makes artifact inaccessible

      When multibranch project contains branch with forward slash in the name (for example `feature/foobar`) corresponding Job gets name `feature%2Ffoobar`  from multibranch pipeline plugin.

      artifact-manager-s3 plugin later uses this name to generate object key:
      https://github.com/jenkinsci/artifact-manager-s3-plugin/blob/master/src/main/java/io/jenkins/plugins/artifact_manager_jclouds/JCloudsArtifactManager.java#L98

      As a result generated artifact will be placed in directory hierarchy like this:

      projectname/feature%2Ffoobar/1/artifacts/example.txt

      However when we try to download this artifact via http url
      https://bucketname.s3.amazonaws.com/projectname/feature%2Ffoobar/1/artifacts/example.txt

      %2F will be converted to forward slash by browser and request fails with NoSuchKey error from AWS.

      When branch name doesn't contain forward slash everything works as expected

          [JENKINS-52151] Forward slash in branch name makes artifact inaccessible

          Jesse Glick added a comment -

          To be clear, by “download” you mean using a browser download from within the web UI displaying artifacts, right?

          Need to verify that copyartifact / unarchive / unstash can perform downloads via presigned URL. That at least should be testable via ArtifactManagerTest.

          Jesse Glick added a comment - To be clear, by “download” you mean using a browser download from within the web UI displaying artifacts, right? Need to verify that copyartifact / unarchive / unstash can perform downloads via presigned URL. That at least should be testable via ArtifactManagerTest .

          > To be clear, by “download” you mean using a browser download from within the web UI displaying artifacts, right?

          No, I mean using ordinary web-browser and going directly to public S3 bucket using link manually constructed from bucket name, project name, branch name and job number.

          However when branch name contains forward slash there is no artifact section on build page at all so I can't check if presigned URLs work or not. In case when branch doesn't have slashes artifact section is present and links from there works fine.

          Regarding access  to artifacts in S3 directly (without going via Jenkins web UI). I don't know if this is currently supported use-case but it would be nice to have (even if it requires manual link generation).
          In our case I wanted to provide these links to QA-team (that don't have access to Jenkins UI) so that they could download them later for testing. Presigned URLs don't work in this situation since they only valid for limited time.

          Andrei Lapshin added a comment - > To be clear, by “download” you mean using a browser download from within the web UI displaying artifacts, right? No, I mean using ordinary web-browser and going directly to public S3 bucket using link manually constructed from bucket name, project name, branch name and job number. However when branch name contains forward slash there is no artifact section on build page at all so I can't check if presigned URLs work or not. In case when branch doesn't have slashes artifact section is present and links from there works fine. Regarding access  to artifacts in S3 directly (without going via Jenkins web UI). I don't know if this is currently supported use-case but it would be nice to have (even if it requires manual link generation). In our case I wanted to provide these links to QA-team (that don't have access to Jenkins UI) so that they could download them later for testing. Presigned URLs don't work in this situation since they only valid for limited time.

          Jesse Glick added a comment -

          Ah, download from the S3 web UI, that is another case I did not consider.

          Various Jenkins steps allow you to download an artifact from this or another build. Additionally, the https://jenkins/job/x/nnn/artifact/dir/file URL is supposed to serve a 301 redirect to a presigned URL you could use for other tools.

          Jesse Glick added a comment - Ah, download from the S3 web UI, that is another case I did not consider. Various Jenkins steps allow you to download an artifact from this or another build. Additionally, the https: //jenkins/job/x/nnn/artifact/dir/file URL is supposed to serve a 301 redirect to a presigned URL you could use for other tools.

          Jesse Glick added a comment -

          In my tests, archiveArtifact, stash, and unstash all work; and I can download the artifact from the AWS Console; but unarchive and opening the artifacts view in the Jenkins UI both fail due to what I think is JCLOUDS-1401.

          Jesse Glick added a comment - In my tests, archiveArtifact , stash , and unstash all work; and I can download the artifact from the AWS Console; but unarchive and opening the artifacts view in the Jenkins UI both fail due to what I think is JCLOUDS-1401 .

          Jesse Glick added a comment -

          A relatively quick fix would be to look at this guide and escape job names with other characters in JCloudsArtifactManager.onLoad, though this would be incompatible from 1.0, mix jclouds aws-s3 limitations into general code, and not solve other problems with odd filenames being archived.

          Jesse Glick added a comment - A relatively quick fix would be to look at this guide and escape job names with other characters in JCloudsArtifactManager.onLoad , though this would be incompatible from 1.0, mix jclouds aws-s3 limitations into general code, and not solve other problems with odd filenames being archived.

          Jesse Glick added a comment -

          Filed a PR with a test, and an upstream fix.

          Jesse Glick added a comment - Filed a PR with a test, and an upstream fix.

          Jon Tancer added a comment -

          jglick

          FYI, the current release of the plugin from July 17th 2018, does not include this fix.  I was able to download the hpi from the latest build on master here https://ci.jenkins.io/job/Plugins/job/artifact-manager-s3-plugin/job/master/ and I can verify this issue is fixed.  When can we expect another official release of this plugin which includes this fix?

          Jon Tancer added a comment - jglick FYI, the current release of the plugin from July 17th 2018, does not include this fix.  I was able to download the hpi from the latest build on master here https://ci.jenkins.io/job/Plugins/job/artifact-manager-s3-plugin/job/master/  and I can verify this issue is fixed.  When can we expect another official release of this plugin which includes this fix?

          Jesse Glick added a comment -

          jtancer best to use JENKINS-50591 for tracking.

          Jesse Glick added a comment - jtancer best to use JENKINS-50591 for tracking.

            jglick Jesse Glick
            alapshin Andrei Lapshin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: