jenkins - 无法在 Jenkins 中使用 emailext 从 Slave 机器和电子邮件附加文件
问题描述
我有一台主机(Unix)和一台从机(Windows)。我已经在 Master 和 Trigger 请求上创建了一个多分支管道项目,所有流程都在 Slave 中进行。我正在尝试发送在从机上生成的 HTML 报告,但得到异常:
ERROR: Error: No workspace found!
Sending email to: abhishek.gaur1@pb.com
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
Finished: SUCCESS
我在 Jenkinsfile 中使用以下代码:
success {
emailext attachmentsPattern: '**/overview-features.html',
body: '${SCRIPT, template="groovy-html.template"}',
mimeType: 'text/html',
subject: 'Success Pipeline: ${currentBuild.fullDisplayName}',
to: 'abhishek.gaur1@pb.com'
}
该文件应附在电子邮件中并发送。目前它显示错误:
错误:找不到工作区!
解决方案
从我的测试来看,这种情况似乎agent none
在配置中存在问题,即工作空间未在主服务器上分配。
agent none
允许在每个阶段设置代理,但该post()
块不允许设置代理,它将在没有工作区的情况下在agent none
我收集的情况下在主服务器上运行。
因此,在这种情况下,声明性管道的唯一解决方案是在带有标签Developer30的代理上运行整个构建,如果您的示例完整,则应该没问题。
pipeline {
agent {
label 'Developer30'
}
tools {
maven 'MAVEN_HOME'
}
stages {
stage ('Compile Stage') {
steps {
bat 'mvn clean'
}
}
}
post {
success {
// emailext stuff
}
}
}
推荐阅读
- xml - $xml.CreateElement 和空节点的表示
- wordpress - WP Job Manager - 声明列表 - 模板覆盖 - 文件夹名称
- android - 我试图在 RecyclerView 中返回我的文档,尽管其中一个字段是类型 timeStamp
- ios - NSString 类内部正在进行什么样的神奇内存管理?
- java - 如何在序列图中重定向方法
- postman - OpenDaylight RESTCONF 是否支持 HTTP PUT 或 POST 方法?
- ios - 在 iOS 上订阅 std::cout 流(stdout)
- react-native - 上传图片 - Strapi - React Native
- ios - Swift - 重试直到网络可达
- javascript - 保存客户端数据到存储优化