Home > Enterprise >  Jenkins artifact short URL / pretty url
Jenkins artifact short URL / pretty url

Time:04-13

How to get a direct short URL for the jenkins build output file.

My last successful build is located at this path.

https://jenkins.domain.com/job/Org_repo_folder/job/project/job/release/build_number/artifact/ApplicationModule/build/outputs/apk/release/AppName_version.apk

How do I access the file with a short URL or path?

Use case:

  1. Long url exposes the build path.
  2. Emails with long urls ends at spam folder.
  3. Build sharing with simple URLs

CodePudding user response:

If you're looking for a Jenkins-internal solution, then you could use the userContent feature.

E.g., Jenkins serves data under $JENKINS_HOME/userContent/file.apk under the URL $JENKINS_URL/userContent/file.apk.

If you copy (or symlink) the data that you want to provide to $JENKINS_HOME/userContent/, then you can use the userContent URL as a short URL for that.

CodePudding user response:

You can use the Sidebar Link Plugin to achieve what you want:

Sidebar Link
Add links in the sidebar of the Jenkins main page, view tabs and project pages.

It will enable you to add a sidebar link at the build level or at the project (job) level. Every time you release a new apk file you can add the release link to the project level with your desired name, for example Latest-Release, and then the artifact will be available via the URL: https://jenkins.domain.com/job/Org_repo_folder/job/project/job/release/Latest-Release
which is the URL of the project combined with the link name you choose.

You are actually creating a redirect from a short link to your long release link.
When you generate the link in your job use the JOB_URL environment variable (or the BUILD_URL if you want the link at the build level) to create the relevant URL.

See the following answer for instructions on using this plugin in pipeline scripts.

  • Related