1
|
def myFile= new File("/tmp/DSL40/configuration.xml")
|
2
|
def parser=new XmlSlurper().parseText(myFile.text);
|
3
|
def allModule=parser.module.each {
|
4
|
def projectName= it.name as String
|
5
|
def sourceCodeType=it.source.@type
|
6
|
def versionCode = it.source.@version
|
7
|
def URLSource=it.source as String
|
8
|
def mvnGoal= it.goal as String
|
9
|
def hasSonar= it.sonar as String
|
10
|
def mail = it.mail as String
|
11
|
def repositoryId = it.deploy.RepositoryId as String
|
12
|
def repositoryURL = it.deploy.RepositoryURL as String
|
13
|
def nightly = it.nightly as String
|
14
|
def cron_node = it.cron as String
|
15
|
println "executing "+projectName
|
16
|
job(type: Maven) {
|
17
|
if (versionCode == '4')
|
18
|
{
|
19
|
if (nightly =='true'){
|
20
|
name 'DSL4_nightly_'+projectName
|
21
|
using ("dnet-nightly-template")
|
22
|
}
|
23
|
else{
|
24
|
name 'DSL4_'+projectName
|
25
|
using ("dnet4-svn-template")
|
26
|
}
|
27
|
}
|
28
|
else{
|
29
|
name 'DSL_'+projectName
|
30
|
using ("dnet-svn-template")
|
31
|
}
|
32
|
|
33
|
triggers
|
34
|
{
|
35
|
if (nightly !='true'){
|
36
|
scm('H/10 * * * *')
|
37
|
}
|
38
|
if (cron_node)
|
39
|
{
|
40
|
cron(cron_node)
|
41
|
}
|
42
|
}
|
43
|
configure {
|
44
|
project ->
|
45
|
def goalModule=project / goals
|
46
|
goalModule.value=mvnGoal
|
47
|
def scm= project / scm
|
48
|
def remoteNode= scm.locations.'hudson.scm.SubversionSCM_-ModuleLocation'[0].remote[0]
|
49
|
remoteNode.value=URLSource
|
50
|
|
51
|
if (mail){
|
52
|
def publishersNode = project /publishers
|
53
|
if (repositoryId) {
|
54
|
def repo_publisher_node= publishersNode.appendNode('hudson.maven.RedeployPublisher')
|
55
|
def repoid_node =repo_publisher_node.appendNode('id')
|
56
|
repoid_node.value = repositoryId
|
57
|
def repourl_node =repo_publisher_node.appendNode('url')
|
58
|
repourl_node.value = repositoryURL
|
59
|
repo_publisher_node.appendNode('uniqueVersion').value='true'
|
60
|
repo_publisher_node.appendNode('evenIfUnstable').value='true'
|
61
|
}
|
62
|
def m1 = publishersNode.appendNode('hudson.plugins.emailext.ExtendedEmailPublisher')
|
63
|
m1.@plugin= "email-ext@2.36"
|
64
|
def rec1 = m1.appendNode('recipientList')
|
65
|
rec1.value= mail
|
66
|
def ct= m1.appendNode('configuredTriggers')
|
67
|
def TriggerNode = ct.appendNode('hudson.plugins.emailext.plugins.trigger.FailureTrigger')
|
68
|
def emailNode = TriggerNode.appendNode('email')
|
69
|
emailNode << {
|
70
|
recipientList ()
|
71
|
subject ('Jenkins Job Problem on $PROJECT_NAME - Build # $BUILD_NUMBER')
|
72
|
body ('$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS: Check console output at $BUILD_URL to view the results.')
|
73
|
sendToDevelopers ('true')
|
74
|
sendToRequester ('true')
|
75
|
includeCulprits('true')
|
76
|
sendToRecipientList('true')
|
77
|
attachmentsPattern('')
|
78
|
attachBuildLog('true')
|
79
|
compressBuildLog('false')
|
80
|
replyTo (mail)
|
81
|
contentType('text/html')
|
82
|
}
|
83
|
TriggerNode.appendNode('attachBuildLog').value='true'
|
84
|
TriggerNode.appendNode('defaultSubject').value='Jenkins Job Problem on $PROJECT_NAME - Build # $BUILD_NUMBER'
|
85
|
TriggerNode.appendNode('defaultContent').value='$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS: Check console output at $BUILD_URL to view the results.'
|
86
|
TriggerNode.appendNode('contentType').value='text/html'
|
87
|
|
88
|
|
89
|
}
|
90
|
if (hasSonar.equals("YES")) {
|
91
|
def pubblish=(project /publishers)
|
92
|
ppNode=pubblish.appendNode('hudson.plugins.sonar.SonarPublisher')
|
93
|
ppNode.@plugin="sonar@2.1"
|
94
|
ppNode.appendNode('jdk').value= '(Inherit From Job)'
|
95
|
}
|
96
|
}
|
97
|
}
|
98
|
}
|