【发布时间】:2020-04-16 19:03:15
【问题描述】:
我们使用每天定期运行的简单管道作业设置了夜间构建,但开发人员没有收到电子邮件通知。
我们使用emailextplugin 发送这些电子邮件,并使用Kubernetes agents 作为节点。
该作业由计时器启动,因为它是定期构建,使其运行以下管道配置(您可以忽略代理的容器定义,因为它不相关,IMO):
pipeline {
agent {
kubernetes {
yaml """
metadata:
labels:
some-label: some-label-value
spec:
containers:
- name: agent
image: python:3.7
command:
- cat
tty: true
"""
}
}
options {
timestamps()
}
stages {
stage('SCM') {
steps {
checkout(
changelog: false,
poll: false,
scm: [$class : 'GitSCM',
userRemoteConfigs : [[credentialsId: 'Git SSH Key', url: 'git@bitbucket.org:company/repository.git']]],
branches : [[name: 'master']],
doGenerateSubmoduleConfigurations: false,
extensions : [[$class : 'CloneOption',
depth : 1,
noTags : false,
reference: '',
shallow : true],
[$class: 'PruneStaleBranch'],
[$class: 'GitLFSPull'],
[$class : 'SubmoduleOption',
disableSubmodules : false,
parentCredentials : true,
recursiveSubmodules: true,
reference : '',
trackingSubmodules : false]],
submoduleCfg : []
)
}
}
stage('Build') {
steps {
container('agent') {
echo '-> install tox'
sh 'pip install tox'
sh 'python --version'
sh 'pip --version'
}
}
}
stage('Test') {
steps {
container('agent') {
sh 'tox -c ./tox.ini'
}
post {
always {
echo '-> collecting artifacts'
archiveArtifacts allowEmptyArchive: true, artifacts: '*.txt'
echo '-> collecting test results'
junit allowEmptyResults: true, testResults: 'output/pytest.xml'
}
}
}
}
}
post {
changed {
emailext(
subject: '$DEFAULT_SUBJECT',
body: '$DEFAULT_CONTENT',
recipientProviders: [culprits(),
developers(),
requestor(),
brokenBuildSuspects(),
brokenTestsSuspects(),
upstreamDevelopers()]
)
}
}
}
当手动启动作业(启动开发人员会收到相关电子邮件)时,上述方法确实有效,但是,当从定期构建(cron)触发作业时 - 收件人列表始终为空:
尝试向空的收件人列表发送电子邮件,被忽略。
可能是什么问题?
【问题讨论】:
标签: jenkins jenkins-pipeline email-ext