How to display a hyperlink in hudson/jenkins build output console

六月ゝ 毕业季﹏ 提交于 2019-12-01 19:51:47

问题


How do I display a hyperlink (weblink) in hudson/jenkins build output console?

What I'm trying to achieve is, during a hudson/jenkins build based on certain condition, I would like to display a hyperlink. When a user click on that link, it should open a new browser window and show the page.

Is there a plugin to do this? Any suggestions please?


回答1:


If you enter, for example:

echo 'http://example.com'

in a Build step Execute shell → Command the address will be hyperlinked in the Console Output, though not with target="_blank". But middle-clicking on it opens it in a new tab or window – depending on your browser preferences.




回答2:


When using a (system) groovy script or Jenkins job pipeline (without sandbox) you may want to try e.g.:

import hudson.console.ModelHyperlinkNote
println hudson.console.ModelHyperlinkNote.encodeTo('http://example.com', 'example')

Please find the full API of hudson.console.ModelHyperlinkNote here: http://javadoc.jenkins-ci.org/hudson/console/ModelHyperlinkNote.html



来源:https://stackoverflow.com/questions/33458321/how-to-display-a-hyperlink-in-hudson-jenkins-build-output-console

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