Project

General

Profile

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
        job(type: Maven) {
16
            if (versionCode == '4')
17
                {                    
18
                    if (nightly =='true'){
19
                    	name 'DSL4_nightly_'+projectName 
20
                    	using ("dnet-nightly-template")	
21
                    }   
22
                    else{
23
                    	name 'DSL4_'+projectName 
24
                    	using ("dnet4-svn-template")
25
                    }
26
                }
27
                else{
28
                    name 'DSL_'+projectName
29
                    using ("dnet-svn-template")
30
                }
31
                
32
                triggers 
33
                {
34
                	if (nightly !='true'){
35
                    	scm('H/10 * * * *')
36
                    }
37
                    if (cron_node)
38
                    {
39
                        cron(cron_node)
40
                    }
41
                }               
42
            configure { 
43
                        project -> 
44
                        def goalModule=project / goals
45
                        goalModule.value=mvnGoal
46
                        def scm= project / scm
47
                        def remoteNode= scm.locations.'hudson.scm.SubversionSCM_-ModuleLocation'[0].remote[0]                                                	
48
                        remoteNode.value=URLSource 
49
                       
50
                        if (mail){
51
                            def publishersNode = project /publishers
52
                            if (repositoryId) {
53
                                    def repo_publisher_node= publishersNode.appendNode('hudson.maven.RedeployPublisher')
54
                                    def repoid_node =repo_publisher_node.appendNode('id')
55
                                    repoid_node.value = repositoryId
56
                                    def repourl_node =repo_publisher_node.appendNode('url')
57
                                    repourl_node.value = repositoryURL
58
                                    repo_publisher_node.appendNode('uniqueVersion').value='true'
59
                                    repo_publisher_node.appendNode('evenIfUnstable').value='true'
60
                                }
61
                            def m1 = publishersNode.appendNode('hudson.plugins.emailext.ExtendedEmailPublisher')
62
                            m1.@plugin= "email-ext@2.36"
63
                            def rec1 = m1.appendNode('recipientList')
64
                            rec1.value= mail
65
                            def ct= m1.appendNode('configuredTriggers')
66
                            def TriggerNode = ct.appendNode('hudson.plugins.emailext.plugins.trigger.FailureTrigger')
67
                            def emailNode = TriggerNode.appendNode('email')
68
                            emailNode  << {
69
                                recipientList ()
70
                                subject ('Jenkins Job Problem on $PROJECT_NAME - Build # $BUILD_NUMBER')
71
                                body ('$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS: Check console output at $BUILD_URL to view the results.')
72
                                sendToDevelopers ('true')
73
                                sendToRequester ('true')
74
                                includeCulprits('true')
75
                                sendToRecipientList('true')
76
                                attachmentsPattern('')
77
                                attachBuildLog('true')
78
                                compressBuildLog('false')
79
                                replyTo (mail)
80
                                contentType('text/html')
81
                            }
82
                            TriggerNode.appendNode('attachBuildLog').value='true'
83
                            TriggerNode.appendNode('defaultSubject').value='Jenkins Job Problem on $PROJECT_NAME - Build # $BUILD_NUMBER'
84
                            TriggerNode.appendNode('defaultContent').value='$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS: Check console output at $BUILD_URL to view the results.'
85
                            TriggerNode.appendNode('contentType').value='text/html'
86

    
87

    
88
                        }                       
89
                        if (hasSonar.equals("YES")) {
90
                            def pubblish=(project /publishers)
91
                            ppNode=pubblish.appendNode('hudson.plugins.sonar.SonarPublisher')
92
                            ppNode.@plugin="sonar@2.1"
93
                            ppNode.appendNode('jdk').value= '(Inherit From Job)'
94
                            }
95
                    }
96
        }
97
}
(4-4/4)