Skip to content
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

fix "FATAL: Null value not allowed as an environment variable: gitlabUserEmail" #170

Closed
wants to merge 1 commit into from
Closed

fix "FATAL: Null value not allowed as an environment variable: gitlabUserEmail" #170

wants to merge 1 commit into from

Conversation

runsisi
Copy link
Contributor

@runsisi runsisi commented Jan 2, 2016

as in gitlab-ce-8.3.0-ce, when we try to get info of opened MRs, gitlab will not return us the email address of the author:

curl http://hust/api/v3/projects/1/merge_requests?state=opened\&private_token=CiQcZ9TLJ3qZD6sy-Ftv

[{"id":6,"iid":6,"project_id":1,"title":"mr3.1","description":"mr3.1",
...
"author":{
"name":"luo.runbing",
"username":"luo.runbing",
"id":2,
"state":"active",
"avatar_url":"http://www.gravatar.com/avatar/3c0c2978976bf9b11c965017aec497a9?s=80\u0026d=identicon",
"web_url":"http://hust/u/luo.runbing"},
...}]

which results error like this:

FATAL: Null value not allowed as an environment variable: gitlabUserEmail

Signed-off-by: runsisi [email protected]

…ab will not

return us the email address of the author:

    curl http://hust/api/v3/projects/1/merge_requests?state=opened\&private_token=CiQcZ9TLJ3qZD6sy-Ftv

    [{"id":6,"iid":6,"project_id":1,"title":"mr3.1","description":"mr3.1",
    ...
    "author":{
    "name":"luo.runbing",
    "username":"luo.runbing",
    "id":2,
    "state":"active",
    "avatar_url":"http://www.gravatar.com/avatar/3c0c2978976bf9b11c965017aec497a9?s=80\u0026d=identicon",
    "web_url":"http://hust/u/luo.runbing"},
    ...}]

which results error like this:

    FATAL: Null value not allowed as an environment variable: gitlabUserEmail

Signed-off-by: runsisi <[email protected]>
@jenkinsadmin
Copy link
Member

Thank you for this pull request! Please check this document for how the Jenkins project handles pull requests.

@WonderCsabo
Copy link
Contributor

I can verify this PR is need and works.

WonderCsabo added a commit to team-supercharge/gitlab-plugin that referenced this pull request Feb 17, 2016
@coder-hugo
Copy link
Contributor

The null check should be move to the location where the getters getName and getEmail of the author are accessed. This change will cause that also the environment variable gitlabUserName isn't set although just the email of the author is null.

@markus-mnm
Copy link
Contributor

I agree with coder-hugo's comment.
This approach worked for me (I could'nt test the other PR without this):

diff --git a/src/main/java/com/dabsquared/gitlabjenkins/GitLabPushTrigger.java b/src/main/java/com/dabsquared/gitlabjenkins/GitLabPushTrigger.java
index 1ef50ad..3a27ace 100644
--- a/src/main/java/com/dabsquared/gitlabjenkins/GitLabPushTrigger.java
+++ b/src/main/java/com/dabsquared/gitlabjenkins/GitLabPushTrigger.java
@@ -396,7 +396,10 @@
         values.put("gitlabActionType", new StringParameterValue("gitlabActionType", "MERGE"));
         if (req.getObjectAttribute().getAuthor() != null) {
            values.put("gitlabUserName", new StringParameterValue("gitlabUserName", req.getObjectAttribute().getAuthor().getName()));
-            values.put("gitlabUserEmail", new StringParameterValue("gitlabUserEmail", req.getObjectAttribute().getAuthor().getEmail()));
+            String email = req.getObjectAttribute().getAuthor().getEmail();
+            if (email!=null) {
+                values.put("gitlabUserEmail", new StringParameterValue("gitlabUserEmail", email));
+            }
         }
         values.put("gitlabMergeRequestTitle", new StringParameterValue("gitlabMergeRequestTitle",  req.getObjectAttribute().getTitle()));
         values.put("gitlabMergeRequestId", new StringParameterValue("gitlabMergeRequestId", req.getObjectAttribute().getIid().toString()));

@demaniak
Copy link
Contributor

demaniak commented Mar 9, 2016

So... any eta on this making it's way downstream? I got people heavily invested and depending on a jenkins-gitlab pipeline, and this is sorta...well...breaking us.

@testark
Copy link

testark commented Mar 9, 2016

We're also needing this. Is there any chance this can get merged soon?

@omehegan
Copy link
Member

omehegan commented Mar 9, 2016

@WonderCsabo can you respond to @coder-hugo's comment? I think that's what we're waiting on.

@WonderCsabo
Copy link
Contributor

@omehegan i am a little bit confused now. I did not get any comment from @coder-hugo . If you are referring to #170 (comment), my reimplementation of this PR (#216), was already created with that comment in mind, actually my PR is the same as this #170 (comment) snippet.

@mfriedenhagen
Copy link
Member

@WonderCsabo
Copy link
Contributor

Exactly.

@omehegan
Copy link
Member

@WonderCsabo sorry, you're right, the original comment was for @runsisi. But it sounds like we should reject this in favor of PR #216. @coder-hugo agree?

@omehegan omehegan closed this Mar 12, 2016
@avdv avdv mentioned this pull request Mar 14, 2016
sh0ked pushed a commit to sh0ked/gitlab-plugin that referenced this pull request May 4, 2016
zbeinanvhtop added a commit to zbeinanvhtop/mirkhalar that referenced this pull request Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants