在 Jenkins 作业的下一步中,我将工件上传到 Artifactory。
stage('Archive Artifacts'){
steps{
rtBuildInfo (captureEnv: true)
rtUpload (
serverId: 'Artifactory-1',
spec: '''{
"files": [
{
"pattern": "app/build/outputs/apk/**/*.apk",
"target": "Spa/Dev/"
}]
}''')
rtPublishBuildInfo (serverId: 'Artifactory-1')
}
}
在发布事件中,我总是使用 email-ext 插件发送电子邮件:
always
{
emailext attachLog: true, mimeType: 'text/html',
body: '''${SCRIPT, template="groovy-html.template"}''',
to: "foo@bar.com",
subject: "Deploy ${env.JOB_NAME} #${env.BUILD_NUMBER}: ${currentBuild.currentResult}"
}
我从这里使用这个模板,这对我来说没问题: https ://github.com/jenkinsci/email-ext-plugin/blob/master/src/main/resources/hudson/plugins/emailext/templates/groovy -html.template
该模板中的 Artifacts 部分:
<!-- ARTIFACTS -->
<%
def artifacts = build.artifacts
if ( artifacts != null && artifacts.size() > 0 ) { %>
<table class="section">
<tr class="tr-title">
<td class="td-title">BUILD ARTIFACTS</td>
</tr>
<% artifacts.each() {
f -> %>
<tr>
<td>
<a href="${rooturl}${build.url}artifact/${f}">${f}</a>
</td>
</tr>
<% } %>
</table>
<br/>
<% } %>
但似乎只有通过“archiveArtifacts”归档时才会填充 build.artifacts:
archiveArtifacts allowEmptyArchive: true, artifacts: 'app/build/outputs/apk/**/*.apk', fingerprint: true, onlyIfSuccessful: true, caseSensitive: false
但是,我想在发送的电子邮件中将存档工件列表发布到 Artifactory。
可能吗?我无法找到 Groovy -> Jenkins -> Artifactory 的任何参考,以便了解脚本中可用的对象或属性。