【问题标题】:Adding video in Allure Report using Allure jenkins plugin使用 Allure jenkins 插件在 Allure Report 中添加视频
【发布时间】:2018-03-02 10:08:52
【问题描述】:

我正在尝试各种方法来使用 Protractor 在 Allure Report 插件中嵌入测试运行视频。 如果我们在 Allure Report 文件夹中添加一个视频文件夹并在 allure description 中添加视频路径,我们可以做到这一点。然后 Allure 在描述部分显示并播放视频。

但是,我想使用 Allure Jenkins 插件来达到同样的效果。如果有任何方法可以在使用 allure jenkins 插件生成的 allure 报告中嵌入和播放视频,请告诉我。

我在 YouTube 上看到了视频,他们在 jenkins 的 Allure 报告中播放视频。但不确定他们是如何设置的。请帮忙? https://www.youtube.com/watch?v=74zD5q9DKTw

【问题讨论】:

  • 嗨,你找到解决办法了吗?如果是,您能解释一下您是如何做到的吗?

标签: protractor jenkins-plugins allure


【解决方案1】:

好像没有“jenkins plugin”的业务,你可以重写 testngListener ,并添加带有“Attachement”的视频

@Override
public void onTestFailure(ITestResult result) {
    super.onTestFailure(result);


    String mp4 = store + "\\" + sessionId + ".mp4";
    File file = new File(mp4);
    if (file.exists()) {
        attachRecord(mp4);
    }

}


@Attachment(value = "record screen", type = "video/mp4")
private byte[] attachRecord(String mp4) {

    System.out.println("mp4 -->" + mp4);
    Path content = Paths.get(mp4);
    InputStream is = null;
    try {
        is = Files.newInputStream(content);
    } catch (IOException e) {
        e.printStackTrace();
    }

    return is2ByeteArray(is);
}


public static byte[] is2ByeteArray(InputStream is) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    byte[] buff = new byte[100];
    int rc = 0;
    while (true) {
        try {
            if (!((rc = is.read(buff, 0, 100)) > 0)) break;
        } catch (IOException e) {
            e.printStackTrace();
        }
        baos.write(buff, 0, rc);
    }

    return baos.toByteArray();
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-23
    • 2023-02-07
    • 2022-11-02
    • 2023-03-28
    相关资源
    最近更新 更多