def createCiPipeline()

in deploy-templates/JobProvisionerRegistryRegulations.groovy [46:93]


def createCiPipeline(pipelineName, codebaseName, codebaseStages, pipelineScript, repository, credId, watchBranch = "master", gitServerCrName, gitServerCrVersion, buildTrigger = "true") {
    def pipelineFullName = "${codebaseName}/${watchBranch.toUpperCase().replaceAll(/\//, "-")}-${pipelineName}"
    pipelineJob(pipelineFullName) {
        logRotator {
            numToKeep(10)
            daysToKeep(7)
        }
        concurrentBuild(false)
        if (buildTrigger) {
            triggers {
                gerrit {
                    events {
                        if (pipelineName.contains("Build"))
                            changeMerged()
                        else
                            patchsetCreated()
                    }
                    project("plain:${codebaseName}", ["plain:${watchBranch}"])
                }
            }
        }
        definition {
            cpsScm {
                scm {
                    git {
                        remote {
                            url(repository)
                            credentials(credId)
                        }
                        branches("${watchBranch}")
                        scriptPath("${pipelineScript}")
                    }
                }
                parameters {
                    booleanParam("FULL_DEPLOY", false, "Select to deploy all files, not only changed")
                    stringParam("GERRIT_PROJECT_NAME", "${codebaseName}", "Gerrit project name(Codebase name) to be build")
                    stringParam("GIT_SERVER_CR_NAME", "${gitServerCrName}", "Name of Git Server CR to generate link to Git server")
                    stringParam("GIT_SERVER_CR_VERSION", "${gitServerCrVersion}", "Version of GitServer CR Resource")
                    stringParam("STAGES", "${codebaseStages}", "Consequence of stages in JSON format to be run during execution")
                    if (pipelineName.contains("Build"))
                        stringParam("BRANCH", "${watchBranch}", "Branch to build artifact from")
                }
            }
        }
    }
    if (buildTrigger && pipelineName.contains("Build"))
        queue pipelineFullName
}