0

we have tried to add a trigger and pull request feature in our building type. When a merge request in GitLab is opened, it will automatically trigger one building. We are using the Pull Request feature.

We have added the followed codes in our Build Types, but when we pushed some changes to the feature branch and open merge requests in Gitlab repo, it does not trigger the building. Or it performs quite weird, when we open MR-1, it does not trigger the building. Then if we open MR-2, it will trigger the MR-1 buildings

myBuildType: BuildType {
 ......
 
 features {
 
 val targetBranch = """
                    +:refs/heads/master
                    """.trimIndent()
    pullRequests {
        vcsRootExtId = "${DslContext.settingsRoot.id}"

        provider = gitlab {
            authType = token {
                token = MY_TOKEN
            }
            filterTargetBranch = targetBranch
            ignoreDrafts = true
        }
    }
 
 }
 
 val trigger = DslContext.getParameter("trigger", "false") == "true"
 if (trigger) {
        triggers {
            vcs {
                triggerRules = "+:."
                branchFilter = """
                +:merge-requests/*
                +:refs/merge-requests/*
                +:master
                """.trimIndent()
            }
        }
    }
    
}

In the project in TeamCity, we set up the VCS root as followed:

Default branch: refs/heads/my_build_settings_branch
Branch specification: +:my_build_settings_branch
                      

Any advice? Thanks

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.