def init()

in src/com/epam/edp/GitInfo.groovy [52:105]


    def init() {
        this.gitServerCrName = job.getParameterValue("GIT_SERVER_CR_NAME")
        this.gitServerCrVersion = job.crApiVersion
        this.gitServerCrApiGroup = "${GIT_SERVER_PLURAL_NAME}.${gitServerCrVersion}.${job.EDP_EPAM_COM_POSTFIX}"
        this.codebaseCrApiGroup = "${CODEBASE_PLURAL_NAME}.${gitServerCrVersion}.${job.EDP_EPAM_COM_POSTFIX}"

        script.println("[JENKINS][DEBUG] Git Server CR Name: ${gitServerCrName}")
        script.println("[JENKINS][DEBUG] Git Server CR Version: ${gitServerCrVersion}")
        script.println("[JENKINS][DEBUG] Git Server CR API Group: ${gitServerCrApiGroup}")

        this.credentialsId = platform.getJsonPathValue(gitServerCrApiGroup, gitServerCrName, ".spec.nameSshKeySecret")
        this.autouser = platform.getJsonPathValue(gitServerCrApiGroup, gitServerCrName, ".spec.gitUser")
        this.host = platform.getJsonPathValue(gitServerCrApiGroup, gitServerCrName, ".spec.gitHost")
        this.sshPort = platform.getJsonPathValue(gitServerCrApiGroup, gitServerCrName, ".spec.sshPort")

        script.println("[JENKINS][DEBUG] credentialsId: ${this.credentialsId}")
        script.println("[JENKINS][DEBUG] autouser: ${this.autouser}")
        script.println("[JENKINS][DEBUG] host: ${this.host}")
        script.println("[JENKINS][DEBUG] sshPort: ${this.sshPort}")

        this.project = defineVariable(["GERRIT_PROJECT", "GERRIT_PROJECT_NAME"])
        this.branch = defineVariable(["GERRIT_BRANCH", "BRANCH", "ghprbActualCommit", "gitlabMergeRequestLastCommit", "COMMIT_ID"])
        this.displayBranch = defineVariable(["GERRIT_BRANCH", "ghprbSourceBranch", "gitlabSourceBranch", "BRANCH"])

        this.normalizedBranch = "${this.branch}".replaceAll("[^\\(?!.)\\p{L}\\p{Nd}]+", "-").toLowerCase()

        switch (job.type) {
            case JobType.CODEREVIEW.value:
                this.changeNumber = defineVariable(["GERRIT_CHANGE_NUMBER", "ghprbPullId", "gitlabMergeRequestIid"])
                this.patchsetNumber = job.getParameterValue("GERRIT_PATCHSET_NUMBER")
                this.refspecName = job.getParameterValue("GERRIT_REFSPEC")
                if (this.patchsetNumber && this.changeNumber)
                    this.changeName = "change-${this.changeNumber}-${this.patchsetNumber}"

                if (!this.changeName)
                    this.changeName = job.getParameterValue("ghprbPullId") ? "pr-${this.changeNumber}" : "mr-${this.changeNumber}"
                break
            case JobType.CREATERELEASE.value:
                this.branch = this.branch ?: ""
                break
            case JobType.BUILD.value:
                this.changeNumber = job.getParameterValue("GERRIT_CHANGE_NUMBER", 0)
                this.patchsetNumber = job.getParameterValue("GERRIT_PATCHSET_NUMBER", 0)
                break
        }
        script.println("[JENKINS][DEBUG]\r\nproject = ${project}\r\nbranch = ${branch}\r\ndisplayBranch = ${displayBranch}")

        if (!this.project)
            script.error("[JENKINS][ERROR] Couldn't determine project, please make sure that GERRIT_PROJECT_NAME variable is defined")
        if (!this.branch && job.type != JobType.CREATERELEASE.value)
            script.error("[JENKINS][ERROR] Couldn't determine branch to clone, please make sure that BRANCH variable is defined")

        this.repositoryRelativePath = platform.getJsonPathValue(codebaseCrApiGroup, this.project, ".spec.gitUrlPath")
    }