Search code examples
restjenkinsjenkins-pipelinejenkins-plugins

Get a jenkins' build url from commit/sha


I need a way to retrieve a jenkins' build url from the commit' sha from which it was built.

I need it because I'm working on an automatic jar downloader that given some infos, like branch, repo, and commit, it downloads the desired artifact. But as I asked, I obviously need the sha to retrieve the correct build.


Solution

  • You could use Jenkins REST API. Iterate over builds https://hostname/job/job_name/api/json and for each build check which commit it built https://hostname/job/job_name/build_number/api/json.