jenkinsci / gitlab-branch-source-plugin

A Jenkins Plugin for GitLab Multibranch Pipeline jobs and Folder Organization
https://plugins.jenkins.io/gitlab-branch-source
MIT License
124 stars 94 forks source link

Adding GITLAB_USER_USERNAME variable to GitLabPushCauseData and GitLabTagPushCauseData #387

Closed janis-pigoznis closed 10 months ago

janis-pigoznis commented 10 months ago

What is done

Added additional variable GITLAB_USER_USERNAME to variables in GitLabPushCauseData and GitLabTagPushCauseData, which contains username of GitLab user who triggered the change. This variable is already available in AbstractPushEvent from org.gitlab4j.api.webhook which is used by these classes, this change only exposes them.

Fixes https://github.com/jenkinsci/gitlab-branch-source-plugin/issues/385

Testing

Tested with simple multibranch pipeline job built on gitlab push event, with following Jenkinsfile

pipeline {
    agent none
    stages {
        stage('print') {
            steps {
                print("env.GITLAB_OBJECT_KIND: " + env.GITLAB_OBJECT_KIND)
                print("env.GITLAB_USER_USERNAME: " + env.GITLAB_USER_USERNAME)
            }
        }
    }
}

Output with latest release of the plugin:

env.GITLAB_OBJECT_KIND: push
env.GITLAB_USER_USERNAME: null

Output with plugin built from this branch:

env.GITLAB_OBJECT_KIND: push
env.GITLAB_USER_USERNAME: janis.pigoznis
### Submitter checklist
- [x] Make sure you are opening from a **topic/feature/bugfix branch** (right side) and not your main branch!
- [x] Ensure that the pull request title represents the desired changelog entry
- [x] Please describe what you did
- [x] Link to relevant issues in GitHub or Jira
- [x] Link to relevant pull requests, esp. upstream and downstream changes
- [x] Ensure you have provided tests - that demonstrates feature works or fixes the issue