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

discoverGitReferenceBuild does not find job with encoded slashes like "release%2F1.41"

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • forensics-api-plugin
    • None
    • Jenkins 2.263.1
      Branch API 2.6.2
      Forensics API Plugin 0.8.0
      Git Forensics Plugin 0.8.0
      Bitbucket Branch Source Plugin 2.9.6

      If Jenkinsfile in a multibranch project "Folder/Repo" runs discoverGitReferenceBuild defaultBranch: 'release/1.41', then the Forensics API Plugin tries to find a job named "Folder/Repo/release/1.41". However, the branch "release/1.41" actually corresponds to the job "Folder/Repo/release%2F1.41"; the slash is encoded as "%2F". Because the name does not match, the Forensics API Plugin does not find the job.

      [ReferenceFinder] There is no such job - maybe the job has been renamed or deleted?

      (The 'release/1.41' string is not actually hardcoded in the Jenkinsfile.)

      It looks like Forensics API Plugin 0.8.0 constructs the "Folder/Repo/release/1.41" string here: https://github.com/jenkinsci/forensics-api-plugin/blob/b1101561ba19c172d561704ae445a146c521cf88/src/main/java/io/jenkins/plugins/forensics/reference/ReferenceRecorder.java#L145

      The Branch API plugin has a NameEncoder class that encodes the slash as "%2F".

      I could perhaps work around this by running discoverGitReferenceBuild defaultBranch: 'release%2F1.41' instead, but I suspect that would break later if the Forensics API Plugin starts asking the Branch API which job corresponds to the specified branch. discoverGitReferenceBuild referenceJob: 'Folder/Repo/release%2F1.41' seems a safer workaround, although more complex to implement.

          [JENKINS-64544] discoverGitReferenceBuild does not find job with encoded slashes like "release%2F1.41"

          Kalle Niemitalo created issue -
          Kalle Niemitalo made changes -
          Description Original: If Jenkinsfile in a multibranch project "Folder/Repo" runs {{discoverGitReferenceBuild defaultBranch: 'release/1.41'}}, then the Forensics API Plugin tries to find a job named "Folder/Repo/release/1.41". However, the branch "release/1.41" actually corresponds to the job "Folder/Repo/release%2F1.41"; the slash is encoded as "%2F". Because the name does not match, the Forensics API Plugin does not find the job.

          bq. \[ReferenceFinder] There is no such job - maybe the job has been renamed or deleted?

          (The 'release/1.41' string is not actually hardcoded in the Jenkinsfile.)

          It looks like Forensics API Plugin 0.8.0 constructs the "Folder/Repo/release/1.41" string here: [https://github.com/jenkinsci/forensics-api-plugin/blob/b1101561ba19c172d561704ae445a146c521cf88/src/main/java/io/jenkins/plugins/forensics/reference/ReferenceRecorder.java#L145]

          The Branch API plugin has a [NameEncoder|https://github.com/jenkinsci/branch-api-plugin/blob/88625a021abc143cf0f5961cdaf13b1cc343529e/src/main/java/jenkins/branch/NameEncoder.java] class that encodes the slash as "%2F".

          I could perhaps work around this by running {{defaultBranch: 'release%2F1.41'}} instead, but I suspect that would break later if the Forensics API Plugin starts asking the Branch API which job corresponds to the specified branch. {{discoverGitReferenceBuild referenceJob: 'Folder/Repo/release%2F1.41'}} seems a safer workaround, although more complex to implement.
          New: If Jenkinsfile in a multibranch project "Folder/Repo" runs {{discoverGitReferenceBuild defaultBranch: 'release/1.41'}}, then the Forensics API Plugin tries to find a job named "Folder/Repo/release/1.41". However, the branch "release/1.41" actually corresponds to the job "Folder/Repo/release%2F1.41"; the slash is encoded as "%2F". Because the name does not match, the Forensics API Plugin does not find the job.

          bq. \[ReferenceFinder] There is no such job - maybe the job has been renamed or deleted?

          (The 'release/1.41' string is not actually hardcoded in the Jenkinsfile.)

          It looks like Forensics API Plugin 0.8.0 constructs the "Folder/Repo/release/1.41" string here: [https://github.com/jenkinsci/forensics-api-plugin/blob/b1101561ba19c172d561704ae445a146c521cf88/src/main/java/io/jenkins/plugins/forensics/reference/ReferenceRecorder.java#L145]

          The Branch API plugin has a [NameEncoder|https://github.com/jenkinsci/branch-api-plugin/blob/88625a021abc143cf0f5961cdaf13b1cc343529e/src/main/java/jenkins/branch/NameEncoder.java] class that encodes the slash as "%2F".

          I could perhaps work around this by running {{discoverGitReferenceBuild defaultBranch: 'release%2F1.41'}} instead, but I suspect that would break later if the Forensics API Plugin starts asking the Branch API which job corresponds to the specified branch. {{discoverGitReferenceBuild referenceJob: 'Folder/Repo/release%2F1.41'}} seems a safer workaround, although more complex to implement.
          Ulli Hafner made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Ulli Hafner made changes -
          Remote Link New: This issue links to "forensics-api-plugin PR#250 (Web Link)" [ 26463 ]
          Ulli Hafner made changes -
          Remote Link New: This issue links to "git-forensics-plugin PR#217 (Web Link)" [ 26464 ]
          Ulli Hafner made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: In Progress [ 3 ] New: Fixed but Unreleased [ 10203 ]
          Ulli Hafner made changes -
          Released As New: https://github.com/jenkinsci/forensics-api-plugin/releases/tag/v0.9.2
          Status Original: Fixed but Unreleased [ 10203 ] New: Resolved [ 5 ]

            drulli Ulli Hafner
            kon Kalle Niemitalo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: