Jenkins의 Email-ext에서 Jelly 전자 메일 템플릿을 작성할 수 있습니다. 매번 빌드를 트리거하지 않고 어떻게 작성하고 테스트합니까? 기본적으로 Jelly 스크립트를 수정하고 브라우저에서 새로 고침을 한 후 1 초 동안 반복하여 하드 코드 프로젝트 및 빌드 결과를 기반으로 템플릿을 자동으로 렌더링합니다.Jenkins의 email-ext에서 Jelly 템플릿을 신속하게 테스트
4
A
답변
7
Jenkins 스크립트 콘솔을 _http : // server/script /에 열면 (Stackoverflow는 실제 URL 일 때 편집 내용을 저장하는 데 문제가 있습니다.)
다음 코드를 입력하고 이메일 주소로 프로젝트의 이름 your-project-name
및 [email protected]
교체 :
import hudson.model.StreamBuildListener
import hudson.plugins.emailext.ExtendedEmailPublisher
import java.io.ByteArrayOutputStream
def projectName = "your-project-name"
def project = Jenkins.instance.getItem(projectName)
try
{
def testing = Jenkins.instance.copy(project, "$projectName-Testing")
def build = project.lastUnsuccessfulBuild
// see the <a href="http://javadoc.jenkins-ci.org/hudson/model/Job.html#getLastBuild()" title="Job" target="_blank">javadoc for the Job class</a> for other ways to get builds
def baos = new ByteArrayOutputStream()
def listener = new StreamBuildListener(baos)
testing.publishersList.each() { p ->
println(p)
if(p instanceof ExtendedEmailPublisher) {
// modify the properties as necessary here
p.recipientList = '[email protected]' // set the recipient list while testing
// run the publisher
p.perform((AbstractBuild<?,?>)build, null, listener)
// print out the build log from ExtendedEmailPublisher
println(new String(baos.toByteArray(), "UTF-8"))
}
}
}
finally
{
if (testing != null)
{
testing.delete()
}
}
자료 제공 : https://earl-of-code.com/2013/02/prototyping-and-testing-groovy-email-templates/
이 쉽게을 추적하는 문제가있다 :
JENKINS-9594 - Should be able to send test e-mail based on previous build
6
이제 테 보다 최신 버전의 플러그인에서 빌드와 비교합니다. 당신이 직업의 스크린에있을 때, 전자 우편 템플렛 테스팅을 밝히는 왼쪽에 연결이 있어야한다. 다시 테스트 할 빌드를 선택하게하고 바로 템플릿을 렌더링합니다.
이 답변은 거의 도움이되지 않습니다. 버그 추적기에 연결하는 것만으로는 질문에 전혀 답할 수 없습니다. –
@ 리차드 (Reichard) 나는 몇 초 전에 방금 실행 한 스크립트를 사용하여 답변을 업데이트했다. 바라기를 이것은 이제 당신에게 만족 스럽습니다. –