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

如何在Jenkins邮件中附加指定文件Zip包而非完整console.log?

解决Jenkins邮件附加指定文件Zip的问题

你当前配置里的attachLog: true和compressLog: true是专门用来附加并压缩构建日志的,所以会生成包含console.log的build.zip。要改成附加指定文件的Zip,按以下方式修改:

核心修改点

  • 移除attachLog: true和compressLog: true这两个日志相关配置
  • 添加指定文件的附件配置,分两种场景选择:

场景1:自动将指定文件打包成Zip

如果需要把一批文件自动打包成一个Zip附加,用attachmentsPattern匹配目标文件,加上zip: true参数即可:

emailext([
    subject: 'Hello World',
    recipientProviders: [developers(), requestor()],
    to: '$DEFAULT_RECIPIENTS',
    body: "hello world",
    mimeType: 'text/html',
    attachmentsPattern: '/path/to/your/target/files/**', // 替换为你的目标文件路径,支持通配符
    zip: true, // 自动将匹配到的文件打包为Zip
    zipFile: 'custom_files.zip' // 可选,自定义Zip包名称,默认是attachments.zip
])

场景2:附加已提前打包好的Zip

如果已经在构建步骤中用命令(比如zip -r my_package.zip ./target/*)把文件打包完成,直接指定这个Zip文件的路径即可:

emailext([
    subject: 'Hello World',
    recipientProviders: [developers(), requestor()],
    to: '$DEFAULT_RECIPIENTS',
    body: "hello world",
    mimeType: 'text/html',
    attachmentsPattern: '/path/to/your/packaged/my_package.zip' // 指向已打包好的Zip文件
])

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.21 05:48:12