首页 > 解决方案 > Jenkins 的 TAP 插件

问题描述

我正在尝试让詹金斯的 TAP 插件工作以消耗来自 perl/prove 的流。我安装了 TAP 插件和 junit 插件。我不确定在哪里或如何安装 tap4j jar,也不确定如何告诉 TAP 插件流文件的写入位置。

按照 TAP 插件的文档,我调用“prove t/ --archive output”,它将流写入输出/t 中的文件:

1..73
ok 1 - use Records;
ok 2 - An object of class 'Relationship' isa 'Relationship'
ok 3 - Relationship->can('rel_insert')
ok 4 - Relationship->can('rel_get')
ok 5 - An object of class 'Records' isa 'Records'
ok 6 - Records->can('IPND_read_file')
ok 7 - Records->can('IPND_read_all_files')
ok 8 - Records->can('IPND_get_our_numbers')
ok 9 - Records->can('IPND_get_tpg_names')
ok 10 - Records->can('IPND_get_tpg_addresses')
ok 11 - Records->can('IPND_sentence_records')
ok 12 - Records->can('IPND_sentence_a_record')
ok 13 - Records->can('IPND_analyse_count')
ok 14 - Records->can('IPND_match_numbers')
ok 15 - Records->can('IPND_dump_to_json')
ok 16 - Records->can('IPND_read_from_json')
ok 17 - Records->can('IPND_dump_sentence')
ok 18 - Records->can('IPND_report_sentence')
ok 19 - Records->can('IPND_report_categories')
ok 20 - Testing listing status: no bits set
ok 21 - Testing listing status: directory bit set
ok 22 - Testing listing status: directory and suppress bits set
ok 23 - Testing listing status: suppress bit set
ok 24 - Testing Installed status: not a number
ok 25 - Testing Installed status: 0
ok 26 - Testing Installed status: just below range
ok 27 - Testing Installed status: range boundary
ok 28 - Testing Installed status: just above range boundary
ok 29 - Testing Installed status: middle of range
ok 30 - Testing Installed status: just before end of range
ok 31 - Testing Installed status: end of range
ok 32 - Testing Installed status: just after range
ok 33 - Testing Installed status: after range
ok 34 - Testing pair exists: both exist
ok 35 - Testing pair exists: first exists
ok 36 - Testing pair exists: second exists
ok 37 - Testing pair exists: neither exists
ok 38 - Testing pair exists: empty hash
ok 39 - Testing cmp_numbers: same number
ok 40 - Testing cmp_numbers: different number
ok 41 - Testing cmp_strings: same string
ok 42 - Testing cmp_strings: different strings
ok 43 - Testing cmp_strings: same string, different case
ok 44 - Testing cmp_strings: different strings, different case
ok 45 - Testing cmp_strings: same string, different case
ok 46 - Testing cmp_strings: different strings, different case
ok 47 - Testing cmp_strings: same string, different case
ok 48 - Testing _cmp_date: first is undef
ok 49 - Testing _cmp_date: second is undef
ok 50 - Testing _cmp_date: both undef
ok 51 - Testing _cmp_date: first is 0
ok 52 - Testing _cmp_date: second is 0
ok 53 - Testing _cmp_date: both 0
ok 54 - Testing _cmp_date: first dashes
ok 55 - Testing _cmp_date: second dashes
ok 56 - Testing _cmp_date: both dashes
ok 57 - Testing _cmp_date: neither dashes
ok 58 - Testing _cmp_date: dieing on first string
ok 59 - Testing _cmp_date: dieing on second string
ok 60 - Testing _cmp_date: dieing on both strings
ok 61 - Testing _cmp_date: less than
ok 62 - Testing _cmp_date: more than
ok 63 - Testing _cmp_date: equal
ok 64 - Testing _bool_to_text: 0
ok 65 - Testing _bool_to_text: 1
ok 66 - Testing _bool_to_text: -1
ok 67 - Testing _bool_to_text: 250
ok 68 - Testing _functionize_params
ok 69 - Testing _Rtrim: space on end
ok 70 - Testing _Rtrim: tab on end
ok 71 - Testing _Rtrim: space on end and beginning
ok 72 - Testing _Rtrim: space on end and tab on beginning
ok 73 - Testing _extract_field

我找不到 TAP 插件的任何配置文件。我也刚刚意识到 tap4j 是一个外部 jar 文件,而不是另一个 jenkins 插件。我已经下载了jar,但现在不知道放在哪里。

总之:

  1. TAP 插件配置文件在哪里
  2. 如何将 TAP 插件指向 output/t 中的流
  3. 我在哪里放置 Tap4j.jar 文件以供 TAP 插件使用。

标签: perljenkinscontinuous-integrationtap

解决方案


好的晦涩难懂 - 即很多很多假设的知识,但是:

  1. 我不知道有一个配置文件 - 反正还没有找到。

  2. 在我的情况下,TAP 流文件位于 output/t 中工作区的根目录之外。在我的 Jenkins 文件中,我放置了一个阶段:

        stage('Report') {
            steps {
                step([$class: "TapPublisher", testResults: "**/output/t/*"])
            }
        }

关键是告诉插件在哪里找到流的最后一位。从字面上看,第一个 ** 表示到处寻找“输出/t” - 即目录路径片段 - 然后在那里将所有内容 - 最后一个“*” - 视为流文件。

  1. 可能有很多地方可以保存 jar 文件,但我将它放在“/plugins/tap/”中。就我而言,在 Ubuntu 20.04 上是 /var/lib/jenkins/plugins/tap。

推荐阅读