Implicit requirement parameter via Kotlin DSL has no value

Hello, I’m trying to set up coverage builds for git merge requests which would be processed by Sonar.
Would you please assist me with the following problem?
I have the following VCSRoot specified (JZCoreGitVcsRoot is set up correctly, I use it in lots of other builds).

package MyProject.vcsRoots

import api.vcs.JZCoreGitVcsRoot

object JZGitVcsRoot : JZCoreGitVcsRoot("JZGitVcsRoot", "u/jz")

And I use it in (passed as featureBranchVcsRoot)

open class SQCQGProjectBaseJZTest(
    parent: String,
    codename: String,
    featureSanityBuildType: BuildType,
    featureBranchVcsRoot: VcsRoot,
    buildTriggers: Triggers.() -> Unit,
    init: Project.() -> Unit = {},
    pipelineConfiguration: SQCQPipelineConfiguration,
    triggerConfig: TriggerConfiguration = TriggerConfiguration(),
) : Project() {
    init {
        ...

        init()
        params {
            ...
        }

        ...

        val mergeRequestSanity = SanityBase {
            ...
        }

        val coverageJacocoFeatureBranch = SonarQubeCodeQualityCoverageJacocoBaseJZTest(
            id = "${parent}_SonarQubeCodeQuality_Project_${codename}_Coverage_Jacoco_Feature_Branch",
            buildTypeName = "Coverage Jacoco : Feature Branch",
            stackEnabled = pipelineConfiguration.isStackEnabled,
            vcsRoot = featureBranchVcsRoot,
            vcsBranchFilter = pipelineConfiguration.vcsBranchFilter,
            sanityBuildType = if (pipelineConfiguration.isMergeRequest) {
                mergeRequestSanity
            } else {
                featureSanityBuildType
            },
            coverageCertifyIgnoreExitCode = pipelineConfiguration.ignoreCoverageCertifyExitCode,
            init = {}
        )

        ...

        buildType(coverageJacocoFeatureBranch)
        buildType(sonarqubeProcessingFeatureBranch)

        if (pipelineConfiguration.processJacocoArtifacts) {
            buildType(coverageJacocoProcessing)
        }
    }
}

and (passed as vcsRoot)

open class SonarQubeCodeQualityCoverageJacocoBaseJZTest(
    id: String,
    buildTypeName: String,
    stackEnabled: Boolean = true,
    vcsRoot: VcsRoot,
    vcsBranchFilter: String = "",
    sanityBuildType: BuildType,
    coverageCertifyIgnoreExitCode: Boolean = true,
    init: BuildType.() -> Unit
) : BuildType() {
    init {
        val isGit = vcsRoot is GitVcsRoot
        ...

        params {
            param("env.BRANCH", "${vcsRoot.paramRefs.buildVcsBranch}")
        }

        vcs {
            checkoutMode = CheckoutMode.MANUAL
            root(vcsRoot)
            if (isGit) {
                branchFilter = vcsBranchFilter
            }
        }

        dependencies {
            snapshot(sanityBuildType) {
                reuseBuilds = ReuseBuilds.SUCCESSFUL
                onDependencyFailure = FailureAction.CANCEL
                synchronizeRevisions = true
            }
        }

        ...

        init()
    }
}

The problem is, that the value of env.BRANCH parameter can’t be determined on TeamCity runtime and the build is not executed as the result.
When the build is waiting in the queue I see a lot of compatible agents. But once it gets on the top of the queue and is about to be executed the situation changes and TeamCity UI suddenly says that there are no compatible agents for this build due to an unmet implicit requirement coming from the parameter env.BRANCH .

0

Please sign in to leave a comment.