如何在Jenkins构建页面上传输mp4工件

时间:2018-02-05 02:23:22

标签: html jenkins video-streaming html5-video jenkins-plugins

如果我点击它,我想要播放mp4工件文件。 enter image description here

然而,当我点击mp4工件文件时,它看起来像下面的图片。它没有播放 enter image description here

如果我下载它然后我可以在我的本地PC上播放它。

所以我尝试使用HTML5嵌入功能进行流式传输。我在下面尝试了两个代码,但是,它们没有用。

<video width="320" height="240" controls autoplay>
  <source src="monkey_result_19.mp4" type="video/mp4">
  Your browser does not support the video tag.
</video>

<video width="320" height="240" controls autoplay>
  <source src="http://xx.xx.xx.xx:8080/view/MonkeyTest/job/test22/lastSuccessfulBuild/artifact/monkey_result_19.mp4" type="video/mp4">
  Your browser does not support the video tag.
</video>

2 个答案:

答案 0 :(得分:1)

对于位于我们的构建工件中的MP4文件,我能够通过添加media-src 'self';和默认的CSP选项来启用视频。

测试更改

System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "sandbox; default-src 'none'; img-src 'self'; style-src 'self'; media-src 'self';")

要在启动时应用更改

java -Dhudson.model.DirectoryBrowserSupport.CSP="sandbox; default-src 'none'; img-src 'self'; style-src 'self'; media-src 'self';" -jar jenkins.war

有关Jenkins内容安全策略的更多信息,请参见Jenkins Docs

答案 1 :(得分:0)

我通过删除安全选项解决了这个问题。 例如,

System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "default-src 'self'; style-src 'self' 'unsafe-inline';")

您可以参考Jenkins Content Security Policy