如何在Jenkins工作中将汇流页面导出为PDF?

时间:2019-04-23 13:37:41

标签: shell jenkins confluence

我正在Shell脚本的帮助下冲洗Jenkins作业,以Confluence中的页面格式导出为PDF,并在构建后将其存储为输出。 我该如何实现?

2 个答案:

答案 0 :(得分:0)

使用wkhtmltopdf进行从html到pdf的转换。

您还可以将现有网站转换为PDF

$wkhtmltopdf  https://wiki.jenkins.io/display/JENKINS/Confluence+Publisher+Plugin#space-menu-link-content demo.pdf

注意:从技术上讲,谷歌浏览器的渲染引擎是Blink,它是Webkit的分支。 Blink和Webkit之间有超过90%的通用代码,因此您应该得到类似的结果。

如果遇到错误

QXcbConnection: Could not connect to display 
Aborted (core dumped)

尝试安装

  

sudo apt-get install xvfb

然后尝试

 xvfb-run wkhtmltopdf  https://wiki.jenkins.io/display/JENKINS/Confluence+Publisher+Plugin#space-menu-link-content demo.pdf

然后您将在jenkins工作区中找到此pdf文件作为输出。

答案 1 :(得分:0)

最后找到一个解决方案:

curl -D- -u user:password -X GET -H "Content-Type: application/json" "<confluence_ url>/spaces/flyingpdf/pdfpageexport.action?pageId=123456789" > curl_ouput.txt
## Read response and extract URL for downloading file
FILE_LOCATION=$(grep "Location: " curl_ouput.txt | sed 's/Location: //g')
## Remove newline character at the end of the url
FILE_LOCATION=${FILE_LOCATION%?}
## Download PDF file
curl -D- -u user:password -X GET -H "Content-Type: text/html;charset=UTF-8" <confluence_url>${FILE_LOCATION} --output fileName.pdf
rm -f curl_ouput.txt
相关问题