You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Artifactory插件正则下载工件并排除指定项报错求助

Jenkins Artifactory插件:匹配含wrapper工件并排除platform-wrapper

需求

下载所有路径包含-wrapper的工件,但排除所有和platform-wrapper相关的工件。

需匹配的工件路径示例

maven-dsd-snapshot-local/com/dsds/aem/tenants/dcihub/dcihub-wrapper/1221.1.0-SNAPSHOT/something-wrapper-2023.1.0-20230206.113149-31.zip

需排除的工件路径示例

maven-dsd-snapshot-local/com/dsds/aem/platform/platform-wrapper/2023.1.0-SNAPSHOT/platform-wrapper-2023.1.0-20230206.113149-51.zip

问题重现

使用带负向断言的正则表达式配置时,触发java.lang.ArrayIndexOutOfBoundsException错误:

Artifactory_BUILD_PATH = """{
               "files": [
              {
                "pattern": "${repo}/(?!.*platform-wrapper).*-wrapper/.*.zip",
                "target": "/tmp/artifacts/",
                "flat": "true",
                "build": "${buildName}/LATEST"
              }
             ]
            }"""

而使用无负向断言的正则${repo}/*-wrapper/*.zip可以匹配所有含wrapper的路径,但无法排除指定项。

解决方案

Artifactory文件匹配支持包含+排除的组合配置,无需复杂负向断言,推荐用以下方式实现需求:

Artifactory_BUILD_PATH = """{
               "files": [
              {
                "pattern": "${repo}/**/*-wrapper/**/*.zip",
                "excludePatterns": ["**/platform-wrapper/**"],
                "target": "/tmp/artifacts/",
                "flat": "true",
                "build": "${buildName}/LATEST"
              }
             ]
            }"""

配置说明

  • pattern: 使用**匹配任意层级路径,确保所有带-wrapper的工件都被选中
  • excludePatterns: 新增排除规则,匹配所有包含platform-wrapper的路径,直接排除这类工件
  • 该方式避免了复杂正则的兼容性问题,逻辑清晰且不会触发数组越界错误

内容的提问来源于stack exchange,提问作者WhoAmI

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 18:50:26