Using BUILD_URL environment variable, I can get path till http://<ip>:8080/job/Nightly_Build/51. Remaining path we can hardcode except value 64 in above path which keep changes when I make changes in pipeline code.
I am unable to get that value on the fly.
Can someone explain what is that 64 number in the path and how can it be retrieved using Jenkins environment variable or APIs?
A bit late to the party, however here is my take on this:
what is that 64 number in the path
This number corresponds to a particular step in the job’s flowgraph. If you open the job instance page in Jenkins and click on “Pipeline Steps” in the left bar you’ll get to the list of all steps that ran as part of that particular job. When you hover on a step the step ID will be displayed. Step #64 should be a “node” step where the current agent and associated workspace were created.
how can it be retrieved using Jenkins environment variable or APIs?
My approach (originating from this discussion) is to create a common step in a Jenkins shared library (e.g., as file library/vars/workspaceUrl.groovy) as such: