<commit_before>// Folders
def workspaceFolderName = "${WORKSPACE_NAME}"
def projectFolderName = "${PROJECT_NAME}"

// Variables
def muleEnvRepoName = "mule"
def muleGitEnvUrl = "ssh://jenkins@gerrit:29418/${PROJECT_NAME}/" + muleEnvRepoName
def devOpsEnvRepoName = "DevOps-ENV"
def devOpsEnvGitUrl = "ssh://jenkins@gerrit:29418/${PROJECT_NAME}/" + devOpsEnvRepoName

// Jobs
def buildJob = freeStyleJob(projectFolderName + "/afp4Mule-Build")
def sonarJob = freeStyleJob(projectFolderName + "/afp4Mule-Sonar")
def packageJob = freeStyleJob(projectFolderName + "/afp4Mule-Package")
def deployJob = freeStyleJob(projectFolderName + "/afp4Mule-Deploy")

// Views
def MuleBuildPipelineView = buildPipelineView(projectFolderName + "/Mule_Code_Pipeline")
MuleBuildPipelineView.with{
    title('Mule Code Pipeline')
    displayedBuilds(5)
    selectedJob(projectFolderName + "/afp4Mule-Build")
    showPipelineParameters()
    showPipelineDefinitionHeader()
    refreshFrequency(5)
}

buildJob.with{
    description("The AFP4Mule application build job.")
    logRotator {
    daysToKeep(7)
    numToKeep(7)
	artifactDaysToKeep(7)
	artifactNumToKeep(7)
    }
    scm {
        git {
            remote {
                url("${muleGitEnvUrl}")
                credentials("adop-jenkins-master")
            }
			branch("*/develop")
		}
    }
	environmentVariables {
        env('WORKSPACE_NAME',workspaceFolderName)
        env('PROJECT_NAME',projectFolderName)
	}	
    wrappers {
        preBuildCleanup()
        injectPasswords()
        maskPasswords()
        sshAgent("adop-jenkins-master")
    }
    triggers {
        gerrit{
            events{
                refUpdated()
            }
            configure { gerritxml ->
                gerritxml / 'gerritProjects' {
                    'com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject' {
                        compareType("PLAIN")
                        pattern(projectFolderName + "/" + muleEnvRepoName)
                        'branches' {
                            'com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch' {
                                compareType("PLAIN")
                                pattern("develop")
                            }
                        }
                    }
                }
                gerritxml / serverName("__ANY__")
            }
        }
    }
	concurrentBuild(false)
    steps {	
		maven {
			mavenInstallation("ADOP Maven")
			goals('clean install -U -DskipTests')
			rootPOM('mule-services-usa/pom.xml')
		}
		systemGroovyScriptFile('/var/jenkins_home/scriptler/scripts/pipeline_params.groovy') {
        }
	}	
    publishers{
		archiveArtifacts {
            pattern('**/*')
			allowEmpty(false)
            onlyIfSuccessful(false)
			fingerprint(true)
			defaultExcludes(true)	
        }
		git {
			pushMerge(false)
            pushOnlyIfSuccess(true)
			forcePush(true)
            tag('origin', '$JOB_NAME-$BUILD_NUMBER') {
                message()
                create(true)
            }
		}
        downstreamParameterized{
            trigger(projectFolderName + "/afp4Mule-Sonar"){
            condition("SUCCESS")
			triggerWithNoParameters(false)
            parameters{
                predefinedProp("B",'${BUILD_NUMBER}')
                predefinedProp("PARENT_BUILD",'${JOB_NAME}')               
                }
            }
        } 
    }
}

sonarJob.with{
    description("Sample AFP4Mule Sonar static code analysis job.")
    logRotator {
    daysToKeep(7)
    numToKeep(7)
	artifactDaysToKeep(7)
	artifactNumToKeep(7)
    }	
    parameters{
        stringParam("B",,"The build number of the parent build.")
        stringParam("PARENT_BUILD",,"The parent build to pull artifacts from.")
    }
	environmentVariables {
        env('WORKSPACE_NAME',workspaceFolderName)
        env('PROJECT_NAME',projectFolderName)
	}
    wrappers {
        preBuildCleanup()
        injectPasswords()
        maskPasswords()
        sshAgent("adop-jenkins-master")
    }
    steps {
        copyArtifacts('${PARENT_BUILD}') {
			buildSelector {
                buildNumber('${B}')
            }
			fingerprintArtifacts(true)
		}
    }
    publishers{
		sonar {
			rootPOM('mule-services-usa/pom.xml')
			additionalProperties('-Dsonar.scm.url=scm:git:https://innersource.accenture.com/digital-1/afp4mule-reference-app.git')
			}			
        downstreamParameterized{
            trigger(projectFolderName + "/afp4Mule-Package"){
				condition("UNSTABLE_OR_BETTER")
				triggerWithNoParameters(false)
				parameters{
                predefinedProp("B",'${BUILD_NUMBER}')
                predefinedProp("PARENT_BUILD",'${PARENT_BUILD}')               
				}
			}
		} 	<commit_msg>Minor code fixes in mule_jobs.groovy script<commit_after>// Folders
def workspaceFolderName = "${WORKSPACE_NAME}"
def projectFolderName = "${PROJECT_NAME}"

// Variables
def muleEnvRepoName = "mule"
def muleGitEnvUrl = "ssh://jenkins@gerrit:29418/${PROJECT_NAME}/" + muleEnvRepoName
def devOpsEnvRepoName = "DevOps-ENV"
def devOpsEnvGitUrl = "ssh://jenkins@gerrit:29418/${PROJECT_NAME}/" + devOpsEnvRepoName

// Jobs
def buildJob = freeStyleJob(projectFolderName + "/afp4Mule-Build")
def sonarJob = freeStyleJob(projectFolderName + "/afp4Mule-Sonar")
def packageJob = freeStyleJob(projectFolderName + "/afp4Mule-Package")
def deployJob = freeStyleJob(projectFolderName + "/afp4Mule-Deploy")

// Views
def MuleBuildPipelineView = buildPipelineView(projectFolderName + "/Mule_Code_Pipeline")
MuleBuildPipelineView.with{
    title('Mule Code Pipeline')
    displayedBuilds(5)
    selectedJob(projectFolderName + "/afp4Mule-Build")
    showPipelineParameters()
    showPipelineDefinitionHeader()
    refreshFrequency(5)
}

buildJob.with{
    description("The AFP4Mule application build job.")
    logRotator {
    daysToKeep(7)
    numToKeep(7)
	artifactDaysToKeep(7)
	artifactNumToKeep(7)
    }
    scm {
        git {
            remote {
                url("${muleGitEnvUrl}")
                credentials("<PASSWORD>")
            }
			branch("*/develop")
		}
    }
	environmentVariables {
        env('WORKSPACE_NAME',workspaceFolderName)
        env('PROJECT_NAME',projectFolderName)
	}	
    wrappers {
        preBuildCleanup()
        injectPasswords()
        maskPasswords()
        sshAgent("adop-jenkins-master")
    }
    triggers {
        gerrit{
            events{
                refUpdated()
            }
            configure { gerritxml ->
                gerritxml / 'gerritProjects' {
                    'com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject' {
                        compareType("PLAIN")
                        pattern(projectFolderName + "/" + muleEnvRepoName)
                        'branches' {
                            'com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch' {
                                compareType("PLAIN")
                                pattern("develop")
                            }
                        }
                    }
                }
                gerritxml / serverName("__ANY__")
            }
        }
    }
	concurrentBuild(false)
    steps {	
		maven {
			mavenInstallation("ADOP Maven")
			goals('clean install -U -DskipTests')
			rootPOM('mule-services-usa/pom.xml')
		}
		systemGroovyScriptFile('/var/jenkins_home/scriptler/scripts/pipeline_params.groovy') {
        }
	}	
    publishers{
		archiveArtifacts {
            pattern('**/*')
			allowEmpty(false)
            onlyIfSuccessful(false)
			fingerprint(true)
			defaultExcludes(true)	
        }
		git {
			pushMerge(false)
            pushOnlyIfSuccess(true)
			forcePush(true)
            tag('origin', '$JOB_NAME-$BUILD_NUMBER') {
                message()
                create(true)
            }
		}
        downstreamParameterized{
            trigger(projectFolderName + "/afp4Mule-Sonar"){
            condition("SUCCESS")
			triggerWithNoParameters(false)
            parameters{
                predefinedProp("B",'${BUILD_NUMBER}')
                predefinedProp("PARENT_BUILD",'${JOB_NAME}')               
                }
            }
        } 
    }
}

sonarJob.with{
    description("Sample AFP4Mule Sonar static code analysis job.")
    logRotator {
    daysToKeep(7)
    numToKeep(7)
	artifactDaysToKeep(7)
	artifactNumToKeep(7)
    }	
    parameters{
        stringParam("B",,"The build number of the parent build.")
        stringParam("PARENT_BUILD",,"The parent build to pull artifacts from.")
    }
	environmentVariables {
        env('WORKSPACE_NAME',workspaceFolderName)
        env('PROJECT_NAME',projectFolderName)
	}
    wrappers {
        preBuildCleanup()
        injectPasswords()
        maskPasswords()
        sshAgent("adop-jenkins-master")
    }
    steps {
        copyArtifacts('${PARENT_BUILD}') {
			buildSelector {
                buildNumber('${B}')
            }
			fingerprintArtifacts(true)
		}
    }
    publishers{
		sonar {
			additionalProperties('-Dsonar.scm.url=scm:git:https://innersource.accenture.com/digital-1/afp4mule-reference-app.git')
			}			
        downstreamParameterized{
            trigger(projectFolderName + "/afp4Mule-Package"){
				condition("UNSTABLE_OR_BETTER")
				triggerWithNoParameters(false)
				parameters{
                predefinedProp("B",'${BUILD_NUMBER}')
                predefinedProp("PARENT_BUILD",'${PARENT_BUILD}')               
				}
			}
		} 	
{'fraction_non_alphanumeric': 0.11120462914255655, 'fraction_numerical': 0.006522882693319305, 'mean_word_length': 2.1529021558872303, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 9}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '343813', 'n_tokens_mistral': 3095, 'n_tokens_neox': 2853, 'n_words': 374}