Home > OS >  Jenkins api4jenkins download last build job console output
Jenkins api4jenkins download last build job console output

Time:06-16

I am trying to get the Jenkins last successful build output using api4jenkins library. I can get the build number, but unable to find the option to download consoletext. Is that option available in this framework?

if not any other way to download the console text using cli?

Thanks SR

CodePudding user response:

You can do something like this.

from api4jenkins import Jenkins

j = Jenkins('http://localhost:8080', auth=('admin', 'admin'))
job = j['Sample'] # Getting the Job by name
for line in job.get_build(1).console_text():
    print(line)

Also remember it's always possible to directly download the log as well. For example refer the following.

http://localhost:8080/job/<JOBNAME>/lastSuccessfulBuild/consoleText

  • Related