Shell 如何在Jenkins job中将合流页面导出为PDF?

Shell 如何在Jenkins job中将合流页面导出为PDF?,shell,jenkins,confluence,Shell,Jenkins,Confluence,在shell脚本的帮助下,我正在编写一个Jenkins作业,将Confluence中的页面导出为PDF,并在构建后将其存储为输出。 如何实现这一点?使用wkhtmltopdf执行从html到pdf的转换 您还可以将现有网站转换为PDF $wkhtmltopdf https://wiki.jenkins.io/display/JENKINS/Confluence+Publisher+Plugin#space-menu-link-content demo.pdf 注意:从技术上讲,Google

在shell脚本的帮助下,我正在编写一个Jenkins作业,将Confluence中的页面导出为PDF,并在构建后将其存储为输出。
如何实现这一点?

使用wkhtmltopdf执行从html到pdf的转换

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

$wkhtmltopdf  https://wiki.jenkins.io/display/JENKINS/Confluence+Publisher+Plugin#space-menu-link-content demo.pdf
注意:从技术上讲,Google Chrome的渲染引擎是Blink,它是Webkit的一个分支。Blink和Webkit之间有超过90%的通用代码,因此您应该会得到类似的结果

如果你得到错误

QXcbConnection: Could not connect to display 
Aborted (core dumped)
尝试安装

sudoapt安装xvfb

然后试试这个

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

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

最后找到一个解决方案:

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
curl-D--u user:password-X GET-H“内容类型:application/json”“/spaces/flyingpdf/pdfpageexport.action?pageId=123456789”>curl\u output.txt
##读取响应并提取下载文件的URL
文件位置=$(grep“LOCATION:”curl_output.txt | sed's/LOCATION://g')
##删除url末尾的换行符
FILE_LOCATION=${FILE_LOCATION%?}
##下载PDF文件
curl-D--u user:password-X GET-H“内容类型:text/html;charset=UTF-8”${FILE\u LOCATION}--output fileName.pdf
rm-f curl\u output.txt