-
Notifications
You must be signed in to change notification settings - Fork 619
Add merge request labels to environment variables #1713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add merge request labels to environment variables #1713
Conversation
src/test/java/com/dabsquared/gitlabjenkins/environment/GitLabEnvironmentContributorTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/dabsquared/gitlabjenkins/environment/GitLabEnvironmentContributorTest.java
Outdated
Show resolved
Hide resolved
krisstern
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @yiftahw, I think this implementation looks good but maybe we could add some instructions on how to use this feature before I can accept and merge this?
|
You can basically just copy and past what you have in the description to the README we have at the root |
@krisstern thinking about what to put in the README, I thought to myself that people that will want to use this feature will probably suffer from some boilerplate of parsing the string held by the environment variable... example pipeline: script {
if (GitLabMergeRequestLabelExists("bugfix"))
{
echo 'bugfix label detected!'
}
}instead of: script {
if (env.gitlabMergeRequestLabels) {
def labels = env.gitlabMergeRequestLabels.split(',').collect { it.trim() }
if ('bugfix' in labels) {
echo 'bugfix label detected!'
}
}
}I'm moving this to draft as I need to add some unit-tests but form initial testing with the docker setup it looks to be working fine |
|
Hi @yiftahw, regarding:
Sounds like a reasonable approach to me! Please go ahead with the implementation. |
krisstern
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more changes before we are good to go
src/test/java/com/dabsquared/gitlabjenkins/workflow/GitLabMergeRequestLabelExistsStepTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/dabsquared/gitlabjenkins/workflow/GitLabMergeRequestLabelExistsStepTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/dabsquared/gitlabjenkins/workflow/GitLabMergeRequestLabelExistsStepTest.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Kris Stern <krisstern@outlook.com>
|
Please apply |
krisstern
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
Hi @yiftahw the PR looks good now, thanks for your contribution! I will let it sit for between 24 and 48 hours before I merge it if there is no objection from the community. |
|
@krisstern before merging, I have some changes that close #1715 , they are pretty minor, should I push these changes here and you'll review them? |
many thanks to @anton-johansson at #901 and @jakub-bochenski at #646 for starting this work
closes #900
Done
GitLabEnvironmentContributorTest.javaGitLabMergeRequestLabelExists("some label") -> BooleanREADME.mdGitLabMergeRequestLabelExistsStepTest.javasrc/docker/README.mdgroovy example of using the helper function:
groovy example of echoing all the labels:
Testing done
Jenkinstag to2.479(withltsI got an error when trying to install the plugin: Jenkins minimum version required: 2.479)latest(17.5),15.11.13-ce.0mvn deployand manually installed to Jenkins with the web UI.Jenkins, integrated it toGitLaband observed the behavior of new environment variable and helper function in push and merge request hooks.Note
Settings -> Integrations -> Jenkins) doesn't send webhooks on comments.Settings -> Webhooks) allows sending hooks on comments, and according to the oldest doc online - GitLab 15.6 Webhook events it does send the labels on comments in merge requests.NoteHookdoesn't handle the labelsSubmitter checklist