0

I have these Jenkins jobs A and B. Job A Builds a bunch of Files for my project. In Job B i wanna execute a command to run a file in the most recent build of job A. My execution even works fine, but only because I have hard coded the build number and I am picking that from the files stored by Jenkins in my C:JenkinsData Directory, I would wanna have that called from the Workspace instead See image for clarification. Jenkins build steps illustration

For e.g my last build right now is 70 I want to know how I can be always executing those same files but in the most recent Build

Or if its even way better Can I execute those same file from Job A since the built files are in the Workspace.

1 Answers1

0

You could get the last build index using this API and "number" property: /lastBuild/api/json

ie: http://localhost:8080/job/yourJobName/lastBuild/api/json

This could help: Jenkins - Get last completed build status

knrf
  • 89
  • 6
  • I can get the build number using the API. Remember Since, My Job B is called to execute immediately after job A completes.. How can I pass that build number in the Build steps of that Job B automatically? – Clinton Ndegwa Nov 09 '22 at 12:58
  • The idea is to get it from a http request using Invoke-WebRequest command or curl before running your command thanks to the lastBuild API above – knrf Nov 09 '22 at 16:22