Project

General

Profile

1 22361 sandro.lab
def myFile= new File("/var/lib/jenkins/jobs/dnet-dsl-job/workspace/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 21970 sandro.lab
        job(type: Maven) {
15 26630 sandro.lab
            if (versionCode == '4')
16
                {
17
                    name 'DSL4_'+projectName
18 26631 sandro.lab
                    using ("dnet4-svn-template")
19 26630 sandro.lab
                }
20 26631 sandro.lab
                else{
21 26630 sandro.lab
                    name 'DSL_'+projectName
22 26631 sandro.lab
                    using ("dnet-svn-template")
23
                }
24
25 21970 sandro.lab
                triggers
26
                {
27 22348 sandro.lab
                    scm('H/10 * * * *')
28 22003 sandro.lab
                }
29 21970 sandro.lab
            configure {
30
                        project ->
31
                        def goalModule=project / goals
32
                        goalModule.value=mvnGoal
33
                        def scm= project / scm
34 26631 sandro.lab
                        def remoteNode= scm.locations.'hudson.scm.SubversionSCM_-ModuleLocation'[0].remote[0]
35 22003 sandro.lab
                        remoteNode.value=URLSource
36
                        if (mail){
37
                            def publishersNode = project /publishers
38 26545 sandro.lab
                            def repo_publisher_node= publishersNode.appendNode('hudson.maven.RedeployPublisher')
39
                            def repoid_node =repo_publisher_node.appendNode('id')
40
                            repoid_node.value = repositoryId
41
                            def repourl_node =repo_publisher_node.appendNode('url')
42
                            repourl_node.value = repositoryURL
43
                            repo_publisher_node.appendNode('uniqueVersion').value='true'
44
                            repo_publisher_node.appendNode('evenIfUnstable').value='true'
45 22003 sandro.lab
                            def m1 = publishersNode.appendNode('hudson.plugins.emailext.ExtendedEmailPublisher')
46
                            m1.@plugin= "email-ext@2.36"
47
                            def rec1 = m1.appendNode('recipientList')
48
                            rec1.value= mail
49
                            def ct= m1.appendNode('configuredTriggers')
50
                            def TriggerNode = ct.appendNode('hudson.plugins.emailext.plugins.trigger.FailureTrigger')
51
                            def emailNode = TriggerNode.appendNode('email')
52
                            emailNode  << {
53
                                recipientList ()
54 22008 sandro.lab
                                subject ('Jenkins Job Problem on $PROJECT_NAME - Build # $BUILD_NUMBER')
55
                                body ('$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS: Check console output at $BUILD_URL to view the results.')
56 22003 sandro.lab
                                sendToDevelopers ('true')
57
                                sendToRequester ('true')
58
                                includeCulprits('true')
59
                                sendToRecipientList('true')
60
                                attachmentsPattern('')
61 22004 sandro.lab
                                attachBuildLog('true')
62 22003 sandro.lab
                                compressBuildLog('false')
63 22004 sandro.lab
                                replyTo (mail)
64 22006 sandro.lab
                                contentType('text/html')
65 22003 sandro.lab
                            }
66 22005 sandro.lab
                            TriggerNode.appendNode('attachBuildLog').value='true'
67 22007 sandro.lab
                            TriggerNode.appendNode('defaultSubject').value='Jenkins Job Problem on $PROJECT_NAME - Build # $BUILD_NUMBER'
68
                            TriggerNode.appendNode('defaultContent').value='$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS: Check console output at $BUILD_URL to view the results.'
69 22010 sandro.lab
                            TriggerNode.appendNode('contentType').value='text/html'
70 22003 sandro.lab
71 22005 sandro.lab
72 22003 sandro.lab
                        }
73 21970 sandro.lab
                        if (hasSonar.equals("YES")) {
74
                            def pubblish=(project /publishers)
75
                            ppNode=pubblish.appendNode('hudson.plugins.sonar.SonarPublisher')
76
                            ppNode.@plugin="sonar@2.1"
77 21972 sandro.lab
                            ppNode.appendNode('jdk').value= '(Inherit From Job)'
78 21970 sandro.lab
                            }
79
                    }
80
        }
81
}