在执行詹金斯(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 -->
<%
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/>
<% } %>
但是似乎build.artifacts仅在通过“ archiveArtifacts”归档时填充:
archiveArtifacts allowEmptyArchive: true, artifacts: 'app/build/outputs/apk/**/*.apk', fingerprint: true, onlyIfSuccessful: true, caseSensitive: false
但是,我想在已发送的电子邮件中将归档工件的列表发布给Artifactory。
有可能吗? 我无法找到Groovy-> Jenkins-> Artifactory的任何参考资料,以便了解脚本中可用的对象或属性。