Skip to content

Accessing labels in build #900

@anton-johansson

Description

@anton-johansson

Issue

Note: MR #646 would've helped me here, but it was never merged.

Context

  • Gitlab plugin version: 1.5.11
  • Gitlab version: 11.7.5
  • Jenkins version: 2.89.4
  • Job type: Pipeline

Logs & Traces

Output from echo sh(returnStdout: true, script: 'env') in build (only showing variables related to this plugin):

gitlabSourceRepoURL=git@git.example.com:group/project.git
gitlabTargetRepoHttpUrl=https://git.example.com/group/project.git
gitlabMergedByUser=anton-johansson
gitlabTargetRepoSshUrl=git@git.example.com:group/project.git
gitlabTargetBranch=master
gitlabMergeRequestIid=1023
gitlabSourceRepoHttpUrl=https://git.example.com/group/project.git
gitlabMergeRequestState=opened
gitlabMergeRequestTitle=Test
gitlabMergeRequestLastCommit=d4f4b002445261f691ec45bffc4dc81534e50f0e
gitlabSourceRepoSshUrl=git@git.example.com:group/project.git
gitlabTargetRepoName=Project
gitlabTargetNamespace=Group
gitlabSourceRepoHomepage=https://git.example.com/group/project
gitlabBranch=anton-test
gitlabSourceBranch=anton-test
gitlabUserEmail=antoon.johansson@gmail.com
gitlabMergeRequestId=5618
gitlabActionType=MERGE
gitlabSourceRepoName=Project
gitlabSourceNamespace=Group
gitlabUserName=Anton Johansson

Problem description

I would like to access MR labels so I can perform various logic depending on them. My main idea here is to automatically deploy to my Kubernetes cluster if a certian label is set. I want this because I don't want to push Docker images to our repository for every commit in every MR. Only the ones that are relevant to deploy.

This also means that I want to be able to trigger a build by only adding a label (this specific label, if possible). Issue #871 states that this is already happening, but it isn't for me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions