Skip to content

Instantly share code, notes, and snippets.

@KyMidd
Created October 2, 2022 16:07
Show Gist options
  • Save KyMidd/d47aa8aa6b3d16e16932317ac8b81bd6 to your computer and use it in GitHub Desktop.
Save KyMidd/d47aa8aa6b3d16e16932317ac8b81bd6 to your computer and use it in GitHub Desktop.
curl -s -X GET -u "$userName:$api_token" "${urlOfJenkinsServer}/job/${jenkinsJobName}/api/json?depth=10&pretty=true&tree=allBuilds\[actions\[buildsByBranchName\[*\[*\[*\]\]\]\]\]" \
| jq ".allBuilds[].actions[].buildsByBranchName \
| select (.[]?.marked.SHA1==\"${commit_sha}\") \
| .\"${branch}\" \
| .buildNumber" \
| sort -r \
| head -n 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment