简体   繁体   中英

Jenkins api4jenkins download last build job console output

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM