How to build and get build log of pipeline job by another pipeline job in jenkins

你离开我真会死。 提交于 2019-12-06 09:05:32
Ahmed Daniel

Try the 'build job' step, available in pipeline syntax. It would be something like:

build job: 'JOB_NAME_A'. OR build 'JOB_NAME_A'

If you have some parameters you can pass them here as well and options to propagate errors or wait till completion of job. (See the pipeline syntax by clicking the pipeline syntax link under script area for full details.)

For getting the log you can try something like:

some_var = build job: 'JOB_NAME_A'

log = Jenkins.getInstance().getItemByFullName(JOB_NAME_A).getBuildByNumber(some_var.getNumber()).logFile.text

some_var stores information of the job you started. This might require script approval from your Jenkins admin and there must be some cleaner way to get this but I'm not sure about that. Haven't tried it with jobs inside folders so you might need to tweak it a bit.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!