Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-branch build jobs don't work when the branch name includes a slash '/' #6

Open
joshOfAllTrades opened this issue Jul 17, 2024 · 6 comments

Comments

@joshOfAllTrades
Copy link

I have a multi-branch build job configured on my Jenkins server. When the branch name contains a slash '/' (which happens when you want to group your branches/PRs based on a Jira ticket or are using certain Git organizations) then CiPol builds an incorrect URL which in turn fails to get the proper status from Jenkins.

For example, if I have the branch name feature/TICKET-1234 and I select the branch build in CiPol, then the URL constructed in CiPol looks like {my_jenkins_host}/job/multibranch_pipeline/job/feature0.000000TICKET-1234.

Obviously, Jenkins has no idea what that URL means, so CiPol status is always gray/unknown and clicking through doesn't work.

@rondorn
Copy link
Owner

rondorn commented Jul 17, 2024 via email

@joshOfAllTrades
Copy link
Author

Interestingly, when you look at the drop-down to add the project, the name of the branch build is feature%2FTICKET-1234, so it's URL encoded at that point.

@rondorn
Copy link
Owner

rondorn commented Jul 17, 2024 via email

@joshOfAllTrades
Copy link
Author

I'm not familiar with Swift, but I'm looking through the code to see if I can spot the issue.

The URL in my browser when I navigate to the job is
{my_jenkins_host}/job/multibranch_pipeline/job/feature%252FTICKET-1234/
while as I said before, the one CiPol produces is
{my_jenkins_host}/job/multibranch_pipeline/job/feature0.000000TICKET-1234

@joshOfAllTrades
Copy link
Author

joshOfAllTrades commented Jul 17, 2024

I think I found it. In Utilities.swift you have this function.

    static func cleanUpURL(url: String)->String {
        
        var cleanUrl = String(format: url)
        cleanUrl = cleanUrl.replacingOccurrences(of: " ", with: "%20")
        
        return cleanUrl
    }

If I'm not mistaken this line var cleanUrl = String(format: url) is interpreting the passed in URL as a printf style format string in which case the URL encoded slash %2F is considered the formatting command for printing a float (only there isn't a parameter so it's formatting null or zero), which is why the resulting URL has the 0.000000 in it.

I can't build/test the Swift, but I think changing that line to

var cleanUrl = url.addingPercentEncoding(withAllowedCharacters: allowedCharacters)

fixes the issue.

@rondorn
Copy link
Owner

rondorn commented Jul 17, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants