1

Currently I'm using the url with lastFailedBuild to display png (capturing page errors) in the browser (jenkins report) : http ://-jenkins-/job/jobName/lastFailedBuild/artifact/screenshots/Fail1.png/

But the problem is : I would be able to store as many artifacts as maximum build I set in the conf. So I would like to keep the artifacts for each build. We can already do it, but the url contains the build number (and I'd like to avoid manipulating the path to get back the build number). Is there a jenkins alias, a plugin, or can we use wildcards for that?

Have an alias like currentBuild wich returns the build number would be perfect (and simple). By 'current build', I mean to refer to the number build report I'm watching, not the last build report.

Also, where are physically stored the artifacts? I mean, I know where the files are stored, in the workspace, but for artifacts the url displays /job/, where is the folder contening artifacts in my jenkins server? Is it a sort of symbolic link to files in workspace?

I wonder : if I delete the image (in the workspace) before each new build, will it keep the previous artifacts ? I think it's yes because when I overwrite a png image the artifact is kept (it seems to me).

I think this topic : aliasing jenkins artifact URLs doesn't answer my question.

More details :

Here my current report, now I want to refer to http ://-jenkins-/job/JDN/55/artifact/screenshots/Fail1.png/ if I'm on build report #55, or http ://-jenkins-/job/JDN/50/artifact/screenshots/Fail1.png/ if I'm on build report #50.

I could do it in my script looking for the last number build but it's a little heavy. I'd like to know if Jenkins manages that, like lastFailedBuild, lastSuccessfulBuild alias. -> an alias which refers to the artifacts of the observed report. -> it could be something as : http ://-jenkins-/job/JDN/currentReportNumber/artifact/screenshots/Fail1.png/

Community
  • 1
  • 1
Fanch
  • 3,274
  • 3
  • 20
  • 51

2 Answers2

2

There is permalink to /lastBuild, which was what I think you mean by "current build"

You can also add /buildNumber to any permalink to get just the value of the build number, for example /lastBuild/buildNumber will return the numeric value of the last executed build, while /lastFailedBuild/buildNumber will return the numeric value of the last failed build.

Physically, the artifacts are stored on the server alongside your WORKSPACE. Under $JENKINS_HOME (or %JENKINS_HOME% for Windows), look for /jobs/<jobname>. There you will see
- config.xml (your job configuration) - nextBuildNumber (contains the next build number, don't modify this) - workspace folder (this is the job's WORKSPACE that Jenkins uses during build - builds folder (this is the history of all your retained builds)

Open the builds folder, and you will see all your saved builds (in time-stamped folders), including symlinks representing the permalinks (such as lastFailedBuild, etc). Under each time-stamped folder, you will see archive folder. This is where the archived artifacts are stored.

To access the WORKSPACE files through the URL use http://<jenkins-url>/job/<job-name>/ws/<path-to-files>

Slav
  • 27,057
  • 11
  • 80
  • 104
  • My bad, when I say 'current build', I want to refer to the build number I'm watching. But /lastBuild/buildNumber will refer to the last executed build for every build, doesn't it? I want to refer to the buildNumber as `job/jobName/55/artifact/`, but something generic for each different build. And I'd like to avoid to look into builds folder in my script to get back the build number. – Fanch May 23 '14 at 13:58
  • Your currently executing build is under `workspace`, not `artifacts` – Slav May 23 '14 at 14:15
  • I just tested and `lastBuild` **does** refer to currently executing build (if there is one currently running), and refers to last executed build (if there are none currently running). However, as I mentioned, it makes little sense to access `artifacts` of currently running build, as that build probably didn't even produce (let alone archive) the artifacts yet. The `artifacts` only makes sense for completed builds. If you need to access workspace files of the currently running build, use `http:///job//ws/` – Slav May 23 '14 at 14:32
  • My bad again, sorry :p I don't want to refer to the artifacts of the current build **executed**, they are not created anyway, I want to refer to the artifacts of the build _report_ I'm **watching**. (current build for me was the report build I was watching, not the current build executed, not very clear it's right). I've edited my question. – Fanch May 23 '14 at 14:54
  • I've read your edit, I don't think what you are asking is possible – Slav May 23 '14 at 15:26
0

Jenkins has a list of variables you can use , see Jenkins Set Environment Variables. So in the shell script launched by the job; you can see the build number with echo $BUILD_NUMBER and use it. Or directly use BUILD_URL.

I obtained the specific url for each build with that.

Fanch
  • 3,274
  • 3
  • 20
  • 51
  • 2
    Never once did you mention that you want to display it within a `build step`. Your question was worded as an external access question. Quote: "display png [...] in the browser". Glad you resolved that. You can type `set` into the `execute shell` step and see a lot more variables that are available to you. – Slav Jun 26 '14 at 13:01
  • Thx :) _display png [...] in the browser_ -> yes and it's exactly what I'm doing. I launch a shell script (jenkins job) which launches a node script (contening casperjs child process). Casperjs exports result in xml (xunit) format that jenkins reads. This xml file contains the url (dependant of the build number) which opens the screen in the browser (reachable via artifact option); took by casperjs. I just didn't want to read files to know the build number. Maybe I should have explain what my job is doing. But you're right I didn't ask for an alias via shell. – Fanch Jun 26 '14 at 13:43