Project

General

Profile

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