Thiago G. Alves
Thiago G. Alves

Reputation: 1399

How to allow only the master branch to trigger builds on Jenkins using GitLab Plugin

I'm trying to restrict only the master branch to can trigger builds on my Jenkins Pipeline.

I already tried "Filter branches by name" and "Filter branches by regex" but nothing has worked.

Someone can help me please?

enter image description here

Thank you...

Upvotes: 0

Views: 2005

Answers (1)

AzarEJ
AzarEJ

Reputation: 552

I also had same problem. And this saved me

To filter according to the payload 'ref' tag, optional filter is set in jenkins pipeline job.

enter image description here

Then applied optional filter on 'ref' variable, to allow only master branch

enter image description here

or expression could be simply

refs/heads/master

Now my jenkins job is triggering only when there is a commit to master


Upvotes: 1

Related Questions