Apache Yetus 配置参数详解
逐项解析 Apache Yetus 0.15.1 的 releasedocmaker 与 test-patch 命令行参数,含帮助原文对照、插件启用规则、personality 定制机制、真实执行回显与常见报错处理。
Apache Yetus 配置参数详解
一、概述
Apache Yetus 0.15.1 的配置主要通过命令行参数与项目级 personality 文件两类方式完成。本文所有参数说明均来自官方二进制包实测(releasedocmaker --help、test-patch --help 的真实回显),并附真实执行示例。
本篇不覆盖工具的安装过程,环境准备请参考《CentOS 8 安装 Apache Yetus 指南》或《Ubuntu 22.04 安装 Apache Yetus 指南》。
二、releasedocmaker 参数详解
2.1 参数总览
releasedocmaker --help 实测回显全文:
usage: releasedocmaker [-h] [--dirversions] [--empty] [--extension EXTENSION]
[--fileversions] [-i] [-l] [-p PROJECT] [--prettyindex]
[-r] [--sortorder TYPE] [--sorttype TYPE] [-t TITLE]
[-u] [-v VERSION] [-V] [-O OUTPUT_DIRECTORY]
[-B BASE_URL] [--retries RETRIES] [--skip-credits]
[-X INCOMPATIBLE_LABEL] [-n LINT]
options:
-h, --help show this help message and exit
--dirversions Put files in versioned directories
--empty Create empty files when no issues
--extension EXTENSION
Set the file extension of created Markdown files
--fileversions Write files with embedded versions
-i, --index build an index file
-l, --license Add an ASF license
-p PROJECT, --project PROJECT
projects in JIRA to include in releasenotes
--prettyindex build an index file with pretty URLs
-r, --range Given versions are a range
--sortorder TYPE Sorting order for sort type (default: older)
--sorttype TYPE Sorting type for issues (default: resolutiondate)
-t TITLE, --projecttitle TITLE
Title to use for the project (default is Apache
PROJECT)
-u, --usetoday use current date for unreleased versions
-v VERSION, --version VERSION
versions in JIRA to include in releasenotes
-V display version information for releasedocmaker and
exit.
-O OUTPUT_DIRECTORY, --outputdir OUTPUT_DIRECTORY
specify output directory to put release docs to.
-B BASE_URL, --baseurl BASE_URL
specify base URL of the JIRA instance.
--retries RETRIES Specify how many times to retry connection for each
URL.
--skip-credits While creating release notes skip the 'reporter' and
'contributor' columns
-X INCOMPATIBLE_LABEL, --incompatiblelabel INCOMPATIBLE_LABEL
Specify the label to indicate backward
incompatibility.
-n LINT, --lint LINT Specify lint filters. Valid filters are
'incompatible', 'important', 'version', 'component',
'assignee'. 'all' enables all lint filters. Multiple
filters can be specified comma-delimited and filters
can be negated, e.g. 'all,-component'.
--project and --version may be given multiple times.
2.2 核心参数说明
| 参数 | 说明 | 实测备注 |
|---|---|---|
| -p / --project | JIRA 项目名,决定从哪个项目拉取 issue | 必须是目标 JIRA 上真实存在的项目,如 YETUS;可多次出现 |
| -v / --version | 要生成文档的版本号,需存在于该项目的 fixVersions | 可多次出现;多版本必须配合 --fileversions 或 --dirversions |
| -O / --outputdir | 输出目录 | 不指定时输出到当前目录 |
| -t / --projecttitle | 文档标题中使用的项目全名 | 缺省为 "Apache PROJECT",建议显式指定 |
| -i / --index | 生成索引文件 index.md | 单版本实测生成的 index.md 为空文件,多版本 + --fileversions 时有实际索引内容 |
| -B / --baseurl | 自建 JIRA 实例地址 | 默认访问 Apache JIRA(issues.apache.org) |
| -l / --license | 在生成文件中加入 ASF 许可声明 | 开源项目发布常用 |
| -X / --incompatiblelabel | 标识不兼容变更的 JIRA 标签 | 配合 RELEASENOTES 的不兼容提示段落使用 |
| -n / --lint | 发布说明质量检查过滤器 | 可用值:incompatible、important、version、component、assignee;支持 all 与取反(如 all,-component) |
| -u / --usetoday | 未发布版本使用当天日期 | 版本尚未设定发布日期时使用 |
| -r / --range | 将多个 --version 视为一个版本区间 | 区间内所有版本的 issue 一并纳入 |
| --empty | 无 issue 时也生成空文件 | 项目存在但该版本无 issue 时生效 |
| --fileversions | 输出文件名中嵌入版本号 | 如 CHANGELOG.0.15.1.md |
| --dirversions | 按版本号创建子目录存放输出 | 与 --fileversions 二选一(多版本时必选其一) |
| --extension | 自定义输出文件扩展名 | 默认 .md |
| --sorttype / --sortorder | issue 排序字段与方向 | 默认按解决日期、由旧到新 |
| --skip-credits | CHANGELOG 表格省略 reporter/contributor 列 | 匿名化场景使用 |
| --retries | 每个请求的重试次数 | 网络不稳定时适当调大 |
| -V | 输出版本号并退出 | 实测输出 0.15.1 |
2.3 常用参数组合示例
单版本生成(实测通过):
releasedocmaker --project YETUS --version 0.15.1 \
--outputdir /tmp/rdm-yetus \
--projecttitle 'Apache Yetus' --index
实测生成文件:CHANGELOG.md(1424 字节)、RELEASENOTES.md(1227 字节)、README.md、index.md。
多版本生成(实测通过):
releasedocmaker --project YETUS --version 0.14.1 --version 0.15.1 \
--outputdir /tmp/rdm-multi \
--projecttitle 'Apache Yetus' \
--index --prettyindex --fileversions
实测生成文件:
CHANGELOG.0.14.1.md
CHANGELOG.0.15.1.md
RELEASENOTES.0.14.1.md
RELEASENOTES.0.15.1.md
README.md
index.md
实测生成的 index.md 内容(节选):
* Apache Yetus vRELEASENOTES.0.15.1.md
* [Changelog](RELEASENOTES.0.15.1.md/CHANGELOG.RELEASENOTES.0.15.1.md)
* [Release Notes](RELEASENOTES.0.15.1.md/RELEASENOTES.RELEASENOTES.0.15.1.md)
* Apache Yetus vRELEASENOTES.0.14.1.md
* [Changelog](RELEASENOTES.0.14.1.md/CHANGELOG.RELEASENOTES.0.14.1.md)
* [Release Notes](RELEASENOTES.0.14.1.md/RELEASENOTES.RELEASENOTES.0.14.1.md)
自建 JIRA 场景(参数写法示例,需将地址与项目替换为实际值):
releasedocmaker --project MYPROJ --version 1.0.0 \
--baseurl https://jira.example.com \
--outputdir ./output --projecttitle 'My Project'
三、test-patch 关键参数详解
3.1 参数总览
test-patch --help 实测回显(分节整理;与隔离运行环境相关的高级参数本文不展开,需要时请查阅官方文档):
test-patch [OPTIONS] patch
Where:
patch is a file, URL, or bugsystem-compatible location of the patch file
Options:
--archive-list=<list> Comma delimited list of pattern matching
notations to copy to patch-dir
--basedir=<dir> The directory to apply the patch to
(default: current directory)
--branch-default=<ref> If the branch isn't forced and we don't
detect one in the patch name, use this
branch (default 'main')
--branch=<ref> Forcibly set the branch
--bugcomments=<bug> Only write comments to the screen and this
comma delimited list (default: 'None: no
plugins enabled')
--build-native=<bool> If true, then build native components
(default 'true')
--build-tool=<tool> Pick which build tool to focus around
(default: autodetect from 'nobuild')
--continuous-improvement=<bool> If true, then do not exit with failure on
branches (default: false)
--contrib-guide=<url> URL to point new users towards project
conventions. (default:
https://yetus.apache.org/documentation/in-pr
ogress/precommit-patchnames )
--debug If set, then output some extra stuff to
stderr
--dirty-workspace Allow the local git workspace to have
uncommitted changes
--empty-patch Create a summary of the current source tree
--excludes=<file> File of regexs to keep project files out of
the set of changes passed to plugins.
--git-offline Do not fail if git cannot do certain remote
operations
--git-shallow Repo does not know about other branches or
tags
--ignore-unknown-options=<bool> Continue despite unknown options (default:
false)
--java-home=<path> Set JAVA_HOME
--linecomments=<bug> Only write line comments to this comma
delimited list (default: same as
--bugcomments)
--list-plugins List all installed plug-ins and then exit
--modulelist=<list> Specify additional modules to test (comma
delimited)
--multijdkdirs=<paths> Comma delimited lists of JDK paths to use
for multi-JDK tests
--multijdktests=<list> Comma delimited tests to use when
multijdkdirs is used. (default:
'compile,unit,javadoc')
--offline Avoid connecting to the network
--patch-dir=<dir> The directory for working and output files
(default '/tmp/test-patch-unknown/pid')
--personality=<file> The personality file to load
--plugins=<list> Specify which plug-ins to add/delete (comma
delimited; use 'all' for all found) e.g.
--plugins=all,-ant,-scalac (all plugins
except ant and scalac)
--proclimit=<num> Limit on the number of processes (default:
2000)
--project=<name> The short name for project currently using
test-patch (default 'yetus')
--report-unknown-options=<bool> Print a warning in the report if
--ignore-unknown-options=true and unknown
options were found (default: true)
--resetrepo Forcibly clean the repo
--run-tests Run all relevant tests below the base
directory
--skip-dirs=<list> Skip following directories for module
finding
--skip-system-plugins Do not load plugins from
/opt/yetus/lib/precommit/plugins.d
--summarize=<bool> Allow tests to summarize results
--test-parallel=<bool> Run multiple tests in parallel (default
false in developer mode, true in Jenkins
mode)
--test-threads=<int> Number of tests to run in parallel (default
defined in unknown build)
--tests-filter=<list> Lists of tests to turn failures into
warnings
--unit-test-filter-file=<file> The unit test filter file to load
--user-plugins=<dir> A directory of user provided plugins.
(default: )
--version Print release version information and exit
Shell binary overrides:
--awk-cmd=<cmd> The 'awk' command to use (default 'awk')
--curl-cmd=<cmd> The 'curl' command to use (default 'curl')
--diff-cmd=<cmd> The GNU-compatible 'diff' command to use (default 'diff')
--file-cmd=<cmd> The 'file' command to use (default 'file')
--git-cmd=<cmd> The 'git' command to use (default 'git')
--grep-cmd=<cmd> The 'grep' command to use (default 'grep')
--patch-cmd=<cmd> The 'patch' command to use (default 'patch')
--sed-cmd=<cmd> The 'sed' command to use (default 'sed')
Automation options:
--build-url-artifacts=<location> Location relative to --build-url of the
--patch-dir (Default:
'artifact/patchprocess')
--build-url-console=<location> Location relative to --build-url of the
console (Default: 'console')
--build-url=<url> Set the build location web page (Default:
'')
--console-report-file=<file> Save the final console-based report to a
file in addition to the screen
--console-urls Use the build URL instead of path on the
console report
--instance=<string> Parallel execution identifier string
--mv-patch-dir Move the patch-dir into the basedir during
cleanup
--robot Assume this is an automated run (default:
auto-detect supported CI system)
--sentinel A very aggressive robot (auto: --robot)
3.2 关键参数说明
| 参数 | 说明 | 实测备注 |
|---|---|---|
| patch(位置参数) | 补丁文件路径、URL 或问题系统中的补丁位置 | 本地文件最常用,如 /tmp/demo.patch |
| --project | 当前接入的项目短名 | 缺省 yetus;影响报告中的项目名与 personality 函数命名空间 |
| --basedir | 应用补丁的仓库目录 | 缺省当前目录;必须是一个 git 仓库 |
| --patch-dir | 工作与输出目录 | 缺省 /tmp/test-patch-unknown/pid;报告、插件结果文件均在此 |
| --plugins | 启用/禁用插件列表 | 逗号分隔;all 表示全部;-plugin 表示剔除。实测默认不启用任何插件,必传 |
| --build-tool | 指定构建工具 | 可选 nobuild、ant、autoconf、cmake、gradle、make、maven;纯 shell 项目用 nobuild |
| --personality | 指定 personality 文件 | 不指定时自动加载 仓库/.yetus/personality.sh(存在即加载) |
| --offline | 避免访问网络 | 内网与离线审计必备 |
| --dirty-workspace | 允许工作区存在未提交修改 | 默认遇脏工作区直接报错退出 |
| --resetrepo | 强制清理还原仓库 | 运行结束后自动还原补丁应用状态 |
| --branch / --branch-default | 强制指定补丁目标分支 / 缺省分支 | 缺省 main;也会从补丁文件名推断 |
| --list-plugins | 列出全部插件并退出 | 用于确认当前可用的构建工具、测试类型、问题系统 |
| --debug | 输出调试信息 | 排查插件未生效等问题时使用 |
| --console-report-file | 将最终报告另存为文件 | CI 归档用 |
| --user-plugins | 用户自定义插件目录 | 默认加载 仓库/.yetus/plugins.d |
| --skip-system-plugins | 不加载系统插件目录 | 仅用自定义插件时使用 |
| --proclimit | 进程数上限 | 默认 2000 |
| --tests-filter | 将指定测试的失败降级为警告 | 灰度接入阶段常用 |
| --empty-patch | 对当前源码树生成汇总报告 | 不传补丁文件时评估存量问题 |
3.3 插件体系与启用规则
test-patch --list-plugins 实测回显:
Reminder: every plug-in may be enabled via 'all'.
BUILDTOOLS:
nobuild ant autoconf cmake gradle make maven
TESTTYPES:
ansiblelint asflicense author blanks buf buflint bufcompat cc checkmake checkstyle codespell detsecrets dupname golang golangcilint hadolint javac javadoc jshint jsonlint markdownlint mvnsite pathlen perlcritic pylint revive rubocop scalac scaladoc shellcheck shelldocs spotbugs test4tests unitveto xmllint yamllint
BUGSYSTEMS:
briefreport bugzilla csvout github gitlab htmlout jira junit slack
TESTFORMATS:
ctest junit tap
实测确认的启用规则:
- 默认不启用任何插件:不传 --plugins 时报告的 Optional Tests 为空,不执行任何测试。
- --plugins=shellcheck,shelldocs,blanks,test4tests 精确启用四个插件,实测正常出报告。
- 插件可组合加减:--plugins=all,-github,-jira 表示启用全部但剔除 github 与 jira。
- 未安装外部工具的插件自动跳过:如未装 pylint,则 pylint 插件不产生投票。
3.4 最小可执行示例
对纯 shell 项目执行审计(实测通过,完整过程见《Apache Yetus 快速入门与集成示例》):
test-patch --project=demo \
--basedir=/opt/demo-shell \
--patch-dir=/tmp/tp-out \
--plugins=shellcheck,shelldocs,blanks,test4tests \
--build-tool=nobuild \
--offline \
/tmp/demo.patch
实测报告关键行:
-1 overall
| +1 | blanks | 0m 0s | The patch has no blanks issues.
| -1 | shellcheck | 0m 1s | The patch generated 1 new + 0 unchanged
| | | | - 0 fixed = 1 total (was 0)
| +1 | shelldocs | 0m 0s | No new issues.
| shellcheck | /tmp/tp-out/results-shellcheck.txt |
| Optional Tests | shellcheck shelldocs |
| Build tool | nobuild |
| versions | git=2.34.1 shellcheck=0.8.0 |
| Powered by | Apache Yetus 0.15.1 https://yetus.apache.org |
审计失败时 test-patch 进程退出码为 1,成功为 0,可直接用于流水线卡点。
3.5 涉及 JVM 构建工具时的建议
test-patch 通过 maven、gradle 等构建工具插件执行编译与单元测试时,JVM 内存按项目规模配置:中型项目建议 export MAVEN_OPTS="-Xmx2g -XX:+UseG1GC",大型多模块项目可到 -Xmx4g;同时可用 --multijdkdirs 与 --multijdktests 做 JDK 矩阵测试。
四、personality 定制机制
4.1 概念
personality 是项目级的定制脚本,约定路径为 仓库根目录/.yetus/personality.sh(存在即自动加载,也可用 --personality 显式指定)。典型用途:
- 通过 personality_plugins 声明默认启用的插件列表;
- 定义 personality_modules 控制模块级测试行为;
- 定义 personality_parse_args / personality_globals 处理项目自定义参数与全局变量;
- 针对构建工具编写项目专属的 file_tests 规则。
一个最小 personality 示例(实测编写并加载):
#!/usr/bin/env bash
# Demo personality: only enable shell checkers
personality_plugins "shellcheck,shelldocs,blanks"
function personality_parse_args
{
echo "demo personality: no extra args"
}
function personality_globals
{
YetusYetusPersonalityFlag=1
}
4.2 实测回显
personality 文件存在时,test-patch 自动加载并在报告尾表中体现:
| Personality | /opt/demo-shell/.yetus/personality.sh |
personality_parse_args 中的 echo 在运行日志中可见:
demo personality: no extra args
4.3 实测重要结论
实测发现(0.15.1,需特别注意):仅在 personality.sh 顶部调用 personality_plugins,不足以让插件在本次运行中生效——调试日志显示 "Using personality plug-in list: shellcheck shelldocs blanks" 确有输出,但插件注册发生在 personality 加载之前,最终报告 Optional Tests 为空、无任何测试投票。
因此当前版本推荐的可靠做法:
- 以命令行 --plugins 显式传参为主(实测稳定生效);
- personality 文件用于模块与文件级规则定制(personality_modules、file tests 等),不依赖它启用插件;
- 如需默认插件集,可在项目 CI 脚本中固化 --plugins 参数。
五、常见问题
Q1: test-patch 报 "ERROR: --dirty-workspace option not provided"?
定位:仓库存在未提交修改或未跟踪文件(含 .yetus 目录本身未入库的情况)。解决:将 .yetus/personality.sh 提交入库,还原其他修改后重跑;无法清理时追加 --dirty-workspace。
Q2: --plugins=all 运行异常退出且无报告?
实测在无远程仓库、无凭据的环境下,all 会连带启用 github、jira 等问题系统插件,出现 "WARNING: --github-repo not autodetermined or provided. Brute forcing."、"error: No such remote 'origin'" 后报告中断。解决:最小环境不要用 all,按需列出测试类插件(如 shellcheck,shelldocs,blanks,test4tests)。
Q3: 提示 "patch does not apply to feature/patch. Rebase required? Wrong Branch?"?
定位:补丁基线分支与当前检出分支不一致(例如补丁从 main 导出,而工作区停留在 feature 分支)。解决:切回补丁的基线分支再运行,或用 --branch/--branch-default 明确目标分支。
Q4: 导出补丁后运行 "成功" 但没有任何测试?
定位:git format-patch 的区间方向写反(如在 main 上执行 git format-patch feature/patch),导出了空补丁,test-patch 无内容可测。解决:在基线分支上使用 git format-patch main..feature/patch --stdout 导出,并核对补丁文件字节数非 0。
Q5: 运行结束后 git status 显示补丁仍应用在工作区?
定位:默认模式运行后不强制还原仓库(nobuild 构建工具的清理为空操作)。解决:git checkout -- 还原文件,或在命令中加 --resetrepo 由 test-patch 自动还原。
六、参考链接
- Apache Yetus 官方文档首页:https://yetus.apache.org/
- releasedocmaker 官方文档:https://yetus.apache.org/documentation/in-progress/releasedocmaker
- test-patch 官方文档:https://yetus.apache.org/documentation/in-progress/precommit/
- precommit-basic 使用指南:https://yetus.apache.org/documentation/in-progress/precommit-basic/
- precommit-personality 定制指南:https://yetus.apache.org/documentation/in-progress/precommit-personality/
- GitHub 仓库:https://github.com/apache/yetus