Project

General

Profile

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