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

Missing URL escaping for job names containing "/"

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Major Major
    • blueocean-plugin
    • None

      We are using the Bitbucket Branch Source Plugin, which creates job names like 'Project/Repo'. Opening those jobs in Blue Ocean results in a 404 page, because the "/" in the job name is interpreted as being part of the URL. Replacing the "/" with "%2F" results in the pages to load correctly.

          [JENKINS-44190] Missing URL escaping for job names containing "/"

          James Dumay added a comment -

          pprkut there are certainly some stage behaviours with the Bitbucket branch source with Blue Ocean. I suspect there is some encoding issues on the Bitbucket branch source that are related to JENKINS-41407 that could be the root cause here.

          Bitbucket support is coming up on our roadmap soon and we hope to clean up a bunch of problems like the one you are describing. I've added this to our Bitbucket Support epic.

          James Dumay added a comment - pprkut there are certainly some stage behaviours with the Bitbucket branch source with Blue Ocean. I suspect there is some encoding issues on the Bitbucket branch source that are related to JENKINS-41407 that could be the root cause here. Bitbucket support is coming up on our roadmap soon and we hope to clean up a bunch of problems like the one you are describing. I've added this to our Bitbucket Support epic.

          James Dumay added a comment - - edited

          pprkut I just played around with jobs with slashes in it and it looks like we are now encoding things correctly with the latest Bitbucket and Blue Ocean plugins.

          See screencast https://www.dropbox.com/s/50v49xwyz6fqkvl/url-paths.gif?dl=0

          James Dumay added a comment - - edited pprkut I just played around with jobs with slashes in it and it looks like we are now encoding things correctly with the latest Bitbucket and Blue Ocean plugins. See screencast https://www.dropbox.com/s/50v49xwyz6fqkvl/url-paths.gif?dl=0

          James Dumay added a comment -

          pprkut I am going to close this for the moment however if this is still a problem for you and you can provide me some step by step reproduction instructions I'd be more than happy to take a deeper dive

          James Dumay added a comment - pprkut I am going to close this for the moment however if this is still a problem for you and you can provide me some step by step reproduction instructions I'd be more than happy to take a deeper dive

          Is this with the latest code in git or with the latest releases? I just applied all available updates here, but that didn't seem to change anything.

          Heinz Wiesinger added a comment - Is this with the latest code in git or with the latest releases? I just applied all available updates here, but that didn't seem to change anything.

          James Dumay added a comment -

          pprkut I used all the latest plugins and Blue Ocean 1.1-beta4 from the experimental update center.

          James Dumay added a comment - pprkut I used all the latest plugins and Blue Ocean 1.1-beta4 from the experimental update center .

          Ok, so with the latest beta versions I can confirm that URLs are working correctly in Blue Ocean.

          However, going from Classic to Blue Ocean via the "Open Blue Ocean" URL is still not working. What happens is this:
          The link in the classic UI is: https://jenkins.example.com/blue/organizations/jenkins/bb%2Fproject/branches
          This returns a 302 response code, with a Location value that's now wrong: https://jenkins.example.com/blue/organizations/jenkins/bb/project/branches/
          (Note the slash at the end, which is the actual reason for the 302 redirection)

          Heinz Wiesinger added a comment - Ok, so with the latest beta versions I can confirm that URLs are working correctly in Blue Ocean. However, going from Classic to Blue Ocean via the "Open Blue Ocean" URL is still not working. What happens is this: The link in the classic UI is: https://jenkins.example.com/blue/organizations/jenkins/bb%2Fproject/branches This returns a 302 response code, with a Location value that's now wrong: https://jenkins.example.com/blue/organizations/jenkins/bb/project/branches/ (Note the slash at the end, which is the actual reason for the 302 redirection)

          James Dumay added a comment -

          pprkut hmm how did you end up with a slash in the name of the organization folder? That is explicitly disallowed by validation. Could you email me some screenshots of the job config page? jdumay@cloudbees.com

          James Dumay added a comment - pprkut hmm how did you end up with a slash in the name of the organization folder? That is explicitly disallowed by validation. Could you email me some screenshots of the job config page? jdumay@cloudbees.com

          There actually is no "/" in the job name. That's all done by blue ocean and/or the bitbucket plugin.

          The URL for Jenkins' classic UI would be https://jenkins.example.com/job/bb/job/project/job/master/

          In this case "bb" would be the owner field in the config ("AS" in your screenshot), and "project" would be the name ("app-store-demo" in your screenshot).
          So based on your example, blue ocean would construct a URL like https://jenkins.example.com/blue/organizations/jenkins/AS%2Fapp-store-demo/branches

          Heinz Wiesinger added a comment - There actually is no "/" in the job name. That's all done by blue ocean and/or the bitbucket plugin. The URL for Jenkins' classic UI would be https://jenkins.example.com/job/bb/job/project/job/master/ In this case "bb" would be the owner field in the config ("AS" in your screenshot), and "project" would be the name ("app-store-demo" in your screenshot). So based on your example, blue ocean would construct a URL like https://jenkins.example.com/blue/organizations/jenkins/AS%2Fapp-store-demo/branches

          James Dumay added a comment -

          pprkut okay that makes sense. However in the screencast I made, you can see that I am unable to reproduce that issue if I use the open blue ocean and back to classic links to jump through the same screens. Is it possible for you to record a screencast for me showing the behaviour? I would need to see the URLs generated.

          James Dumay added a comment - pprkut okay that makes sense. However in the screencast I made, you can see that I am unable to reproduce that issue if I use the open blue ocean and back to classic links to jump through the same screens. Is it possible for you to record a screencast for me showing the behaviour? I would need to see the URLs generated.

          Hmm, don't think I can get a screencast up anytime soon. Trying with a screenshot.
          I opened the html source and highlighted the URL for the "Open Blue Ocean" button. One thing I noticed is that for you the link to blue ocean was in the sidebar, not sure if that's relevant though

          Heinz Wiesinger added a comment - Hmm, don't think I can get a screencast up anytime soon. Trying with a screenshot. I opened the html source and highlighted the URL for the "Open Blue Ocean" button. One thing I noticed is that for you the link to blue ocean was in the sidebar, not sure if that's relevant though

          James Dumay added a comment -

          pprkut hmm, we might be calculating the URL differently now.

          vivek did we change the way the link for "Open Blue Ocean" is generated on master (compared with 1.0.x)?

          James Dumay added a comment - pprkut hmm, we might be calculating the URL differently now. vivek did we change the way the link for "Open Blue Ocean" is generated on master (compared with 1.0.x)?

          FWIW, that's actually 1.1.0-beta-4, not 1.0.x

          Heinz Wiesinger added a comment - FWIW, that's actually 1.1.0-beta-4, not 1.0.x

          Vivek Pandey added a comment - - edited

          A bug was fixed sometime back and we started encoding pipeline name, that sounds correct for it to work correctly. This issue is strange.

          pprkut can you provide steps to create such job, specially repo name on Bitbucket that's resulting in blueocean getting the name with '/' in it however classic still gets it correctly.

          Better yet, if you could provide a public Bitbucket repo that we can use to reproduce it will be super helpful.

          Vivek Pandey added a comment - - edited A bug was fixed sometime back and we started encoding pipeline name, that sounds correct for it to work correctly. This issue is strange. pprkut can you provide steps to create such job, specially repo name on Bitbucket that's resulting in blueocean getting the name with '/' in it however classic still gets it correctly. Better yet, if you could provide a public Bitbucket repo that we can use to reproduce it will be super helpful.

          There's nothing special that needs to be done. The job jamesdumay used as an example would already exhibit the same problem. The only difference between his setup and mine with regards to Bitbucket is that he created a job for a single repository specifically, whereas we configure a "Bitbucket Team/Project" type job as root element.

          The "/" is coming from the Bitbucket plugin, not from naming in Bitbucket.

          Heinz Wiesinger added a comment - There's nothing special that needs to be done. The job  jamesdumay  used as an example would already exhibit the same problem. The only difference between his setup and mine with regards to Bitbucket is that he created a job for a single repository specifically, whereas we configure a "Bitbucket Team/Project" type job as root element. The "/" is coming from the Bitbucket plugin, not from naming in Bitbucket.

          James Dumay added a comment -

          pprkut ahh! I didn't think of that type - sorry if I missed it. Yes, there is something odd going on there. I suspect it isn't properly encoded within the bitbucket plugin

          James Dumay added a comment - pprkut ahh! I didn't think of that type - sorry if I missed it. Yes, there is something odd going on there. I suspect it isn't properly encoded within the bitbucket plugin

          To be honest, I'm not sure that's it. If that were the case, it wouldn't work for you when you switch between classic and blue ocean either. In that URL it's encoded properly. It's the value of the URL returned in the Location header in case of redirects that's still wrong, at least here.

          Heinz Wiesinger added a comment - To be honest, I'm not sure that's it. If that were the case, it wouldn't work for you when you switch between classic and blue ocean either. In that URL it's encoded properly. It's the value of the URL returned in the Location header in case of redirects that's still wrong, at least here.

          James Dumay added a comment -

          pprkut I'm using a "Multibranch Project" with a Bitbucket SCM source - I believe they are different?

          James Dumay added a comment - pprkut I'm using a "Multibranch Project" with a Bitbucket SCM source - I believe they are different?

          jamesdumay No it's the same. The only difference is in the hierarchy level with regards to navigation in Jenkins / Blue Ocean. Take your "AS/app-store-demo" repo as an example.
          With a simple Multibranch Project Job navigation is this:

          Jenkins -> AS/app-store-demo

          With a Bitbucket Team/Project Job navigation would be

          Jenkins -> AS -> AS/app-store-demo

          It doesn't change the fact that there is a "/" in the job name

          Heinz Wiesinger added a comment - jamesdumay No it's the same. The only difference is in the hierarchy level with regards to navigation in Jenkins / Blue Ocean. Take your "AS/app-store-demo" repo as an example. With a simple Multibranch Project Job navigation is this: Jenkins -> AS/app-store-demo With a Bitbucket Team/Project Job navigation would be Jenkins -> AS -> AS/app-store-demo It doesn't change the fact that there is a "/" in the job name

          James Dumay added a comment -

          pprkut I downgraded to Blue Ocean 1.0.1 this morning and created a "Bitbucket Team/Project" item. Here is a screencast of my reproduction steps. I was unable to see the encoding issue with these new steps. Is there something I am missing here?

          Hmm, you wouldn't happen to have a HTTP reverse proxy in front of Blue Ocean would you?

          James Dumay added a comment - pprkut I downgraded to Blue Ocean 1.0.1 this morning and created a "Bitbucket Team/Project" item. Here is a screencast of my reproduction steps. I was unable to see the encoding issue with these new steps. Is there something I am missing here? Hmm, you wouldn't happen to have a HTTP reverse proxy in front of Blue Ocean would you?

          You're right. I do have nginx in front of jenkins. Just tried without it and it does work when nginx is not involved. The redirection (because of the missing "/" at the end of the URL) is still there though, just in this scenario the returned Location header doesn't contain a decoded URL. So if we could still add that slash it would still help.

          In the meantime, I'll try to figure out why nginx decodes the returned location URL :-/

          Heinz Wiesinger added a comment - You're right. I do have nginx in front of jenkins. Just tried without it and it does work when nginx is not involved. The redirection (because of the missing "/" at the end of the URL) is still there though, just in this scenario the returned Location header doesn't contain a decoded URL. So if we could still add that slash it would still help. In the meantime, I'll try to figure out why nginx decodes the returned location URL :-/

          James Dumay added a comment -

          pprkut if you follow this guide carefully it should show you how to get the encoding to work properly so that the slash gets passed through. I believe there is something in the way that Jenkins double encodes spaces and slashes that sometimes gets stripped out by the proxy.

          James Dumay added a comment - pprkut if you follow this guide carefully it should show you how to get the encoding to work properly so that the slash gets passed through. I believe there is something in the way that Jenkins double encodes spaces and slashes that sometimes gets stripped out by the proxy.

            jamesdumay James Dumay
            pprkut Heinz Wiesinger
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: