gitlab-plugin icon indicating copy to clipboard operation
gitlab-plugin copied to clipboard

Ability to build tag without "triggerOnPush"

Open gpongelli opened this issue 1 year ago • 1 comments

What feature do you want to see added?

Hi, in the use case where I want to build only tags and branches under MR, without building EACH branch pushed, I've setup the plugin in following way:

triggers {
        gitlab(branchFilterType: 'All',
            excludeBranchesSpec: '',
            includeBranchesSpec: '',
            cancelPendingBuildsOnUpdate: false,
            ciSkip: true,
            noteRegex: '([Jj]enkins).*(retry).*',
            pendingBuildName: '',
            secretToken: '[REDACTED]',
            setBuildDescription: true,
            skipWorkInProgressMergeRequest: true,
            sourceBranchRegex: '',
            targetBranchRegex: '',
            addVoteOnMergeRequest: true,
            triggerOnAcceptedMergeRequest: false,
            triggerOnApprovedMergeRequest: false,
            triggerOnClosedMergeRequest: false,
            triggerOnMergeRequest: true,
            triggerOnNoteRequest: true,
            triggerOnlyIfNewCommitsPushed: true,
            triggerOpenMergeRequestOnPush: 'source',
            triggerOnPush: false,
            triggerOnPipelineEvent: false,
            triggerToBranchDeleteRequest: false)
    }

with this configuration I can buid branches under MR but tags cannot be built.

The only way to trigger tag builds is changing triggerOnPush: false to true, but the drawback is that EVERY pushed branch will be built (and it's something not wanted).

Is it possible to have a checkmark to explicitly select "Tag Push Event"?

Thanks.

Upstream changes

No response

Are you interested in contributing this feature?

I've no idea on how to contribute.

gpongelli avatar Dec 04 '24 11:12 gpongelli

Hello. I believe I'm a little bit late. Anyway, I believe there are several ways to solve this.

  1. Use Jenkins integration inside GitLab and click on Tag push only if you don't want to build for any commit push without a tag.
  2. If you use Multibranch Pipeline, you can install Basic Branch Build Strategies to make it build for filtered tags (by time) and/or filtered branches (by names).
  3. If you use a pure pipeline, you can use the argument sourceBranchRegex of the GitLab trigger to filter the ref of the GitLab webhook attribute to allow tags which start with "refs/tags/", like ^ref/tags/.*$, and/or other specific branches if you want. Just treat tags like branches.

dodo920306 avatar Apr 17 '25 10:04 dodo920306