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