jenkinsci / jenkinsci/jfrog-plugin

rt build-publish not handling special characters in job names

Open
#28 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
16
Forks
85
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug

Build info records for Jenkins jobs with special characters in the name are broken. Accessing the build info through the “Artifactory Build Info” link inside Jenkins and the Artifactory UI does not work as intended. It appears to be related to disagreements in URL encoding between the Jenkins plugin, the generated build-info file, and Artifactory.

### Current behavior

I created a minimum job that published the following job-info file for testing:
```json
{
"version" : "1.0.1",
"name" : "foo/bar",
"number" : "3",
"buildAgent" : {
"name" : "GENERIC",
"version" : "2.53.2"
},
"agent" : {
"name" : "jenkins-jfrog-plugin",
"version" : "1.5.0"
},
"started" : "2024-03-08T17:54:38.413+0000",
"durationMillis" : 0,
"artifactoryPrincipal" : "bot@example.com",
"url" : "https://jenkins.example.com/job/foo/job/bar/3/"
}
```
The record itself appears as `artifactory-build-info/foo%2Fbar/3-1709920478413.json` in Artifactory.

When using the info link generated by Jenkins, for example, https://artifactory.example.com/ui/builds/foo%2Fbar/3/1709920478413/published?buildRepo=artifactory-build-info, I am redirected to the Artifactory home page. My web console shows I got a 404 for the requested page before the redirect.

When I attempt to navigate to the build in the Artifactory UI (https://artifactory.example.com/ui/builds/foo%2Fbar/?buildRepo=artifactory-build-info) the page hangs and never loads.
![Screenshot from 2024-03-08 14-10-36](https://github.com/jenkinsci/jfrog-plugin/assets/8305591/e2fc24b3-2777-43b8-b330-8db2eb3beff3)

Using the web console, I can see that it is getting a 404 trying to POST to the API (https://artifactory.example.com/ui/api/v1/global-search/builds/foo%2Fbar?jfLoader=false).

Digging into it a bit, if I manually upload a build-info file replacing the name `foo/bar` with `foo%2Fbar` it generates a `artifactory-build-info/foo%252Fbar/3-1709920478413.json` record that does work as intended in the Artifactory UI, with the caveat that it appears as `foo%2Fbar` instead of `foo/bar` in the build-info menu.

This appears to be related to some URL encoding disagreements between the plugin and Artifactory. I am not sure which is at fault exactly, but I would love to see a workaround or fix for this issue, as not having access to build info is also breaking things like artifact promotion.

### Reproduction steps

1. create a Jenkins pipeline within a folder, or a multi-branch job ex. `foo/bar`
2. use the plugin to publish build info `jf "rt build-publish"`
3. Try and view the build info in the Artifactory UI, or use the Build Info link in Jenkins

### Expected behavior

You should be able to access the build info via the Jenkins link and view it in the Artifactory UI.

### JFrog plugin version

1.5.0

### JFrog CLI version

2.53.2

### Operating system type and version

linux, ubuntu, 22.04

### JFrog Artifactory version

7.77.6

### JFrog Xray version

n/a

Contributor guide

Open the contributing guide

Research direction

Start at the rt build-publish entry point and trace how the plugin writes the build-info name and constructs the Jenkins and Artifactory links. Reproduce with a folder job named foo/bar, then verify that the generated record can be opened from both links and in the Artifactory UI without changing the displayed name.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.