How to get ONLY unblocked author email of git commit










-1















I need to send an email notification from jenkins to the authors of a git commit.



To get git commit authors, I used a sh script:



git_emails = sh ( 
script: "git log --format='%cE%n%aE%n%gE' $gitLogCommand | sort -u",
returnStdout: true
).trim()


Before sending an email, I need to check if the returned authors are blocked or not in Gitlab.



is any one have an idea how to do that ! Thank you.



Edit: Block user from Gitlab



enter image description here










share|improve this question



















  • 2





    What do you mean, blocked authors? AFAIK, git has no concept of blocking. Are you mixing up git and GitHub? You can check whether you've blocked a user using GitHub's GET /user/blocks/:username API v3 endpoint.

    – Amadan
    Nov 13 '18 at 11:08












  • In gitLab, I can block users from admin area. once it's done, user will blocked in the platform and he can't connect with his account even he already pushed some commits. In this case, Jenkins shouldn't send emails any more for these blocked users

    – Imen
    Nov 13 '18 at 12:08











  • As I said, that's GitHub functionality, not git. The two are very different things.

    – Amadan
    Nov 13 '18 at 12:10






  • 1





    How could it be only on Github since I can do it from my Gitlab admin area ? Please check My edit, I added a screenshot to the functionality in Gitlab !

    – Imen
    Nov 13 '18 at 12:17











  • Ah, sorry, I misread. Then, it is your GitLab functionality (GitLab being a clone of GitHub, they have similar functions.) Not git.

    – Amadan
    Nov 13 '18 at 12:17
















-1















I need to send an email notification from jenkins to the authors of a git commit.



To get git commit authors, I used a sh script:



git_emails = sh ( 
script: "git log --format='%cE%n%aE%n%gE' $gitLogCommand | sort -u",
returnStdout: true
).trim()


Before sending an email, I need to check if the returned authors are blocked or not in Gitlab.



is any one have an idea how to do that ! Thank you.



Edit: Block user from Gitlab



enter image description here










share|improve this question



















  • 2





    What do you mean, blocked authors? AFAIK, git has no concept of blocking. Are you mixing up git and GitHub? You can check whether you've blocked a user using GitHub's GET /user/blocks/:username API v3 endpoint.

    – Amadan
    Nov 13 '18 at 11:08












  • In gitLab, I can block users from admin area. once it's done, user will blocked in the platform and he can't connect with his account even he already pushed some commits. In this case, Jenkins shouldn't send emails any more for these blocked users

    – Imen
    Nov 13 '18 at 12:08











  • As I said, that's GitHub functionality, not git. The two are very different things.

    – Amadan
    Nov 13 '18 at 12:10






  • 1





    How could it be only on Github since I can do it from my Gitlab admin area ? Please check My edit, I added a screenshot to the functionality in Gitlab !

    – Imen
    Nov 13 '18 at 12:17











  • Ah, sorry, I misread. Then, it is your GitLab functionality (GitLab being a clone of GitHub, they have similar functions.) Not git.

    – Amadan
    Nov 13 '18 at 12:17














-1












-1








-1








I need to send an email notification from jenkins to the authors of a git commit.



To get git commit authors, I used a sh script:



git_emails = sh ( 
script: "git log --format='%cE%n%aE%n%gE' $gitLogCommand | sort -u",
returnStdout: true
).trim()


Before sending an email, I need to check if the returned authors are blocked or not in Gitlab.



is any one have an idea how to do that ! Thank you.



Edit: Block user from Gitlab



enter image description here










share|improve this question
















I need to send an email notification from jenkins to the authors of a git commit.



To get git commit authors, I used a sh script:



git_emails = sh ( 
script: "git log --format='%cE%n%aE%n%gE' $gitLogCommand | sort -u",
returnStdout: true
).trim()


Before sending an email, I need to check if the returned authors are blocked or not in Gitlab.



is any one have an idea how to do that ! Thank you.



Edit: Block user from Gitlab



enter image description here







git jenkins jenkins-pipeline






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 12:24







Imen

















asked Nov 13 '18 at 11:06









ImenImen

619




619







  • 2





    What do you mean, blocked authors? AFAIK, git has no concept of blocking. Are you mixing up git and GitHub? You can check whether you've blocked a user using GitHub's GET /user/blocks/:username API v3 endpoint.

    – Amadan
    Nov 13 '18 at 11:08












  • In gitLab, I can block users from admin area. once it's done, user will blocked in the platform and he can't connect with his account even he already pushed some commits. In this case, Jenkins shouldn't send emails any more for these blocked users

    – Imen
    Nov 13 '18 at 12:08











  • As I said, that's GitHub functionality, not git. The two are very different things.

    – Amadan
    Nov 13 '18 at 12:10






  • 1





    How could it be only on Github since I can do it from my Gitlab admin area ? Please check My edit, I added a screenshot to the functionality in Gitlab !

    – Imen
    Nov 13 '18 at 12:17











  • Ah, sorry, I misread. Then, it is your GitLab functionality (GitLab being a clone of GitHub, they have similar functions.) Not git.

    – Amadan
    Nov 13 '18 at 12:17













  • 2





    What do you mean, blocked authors? AFAIK, git has no concept of blocking. Are you mixing up git and GitHub? You can check whether you've blocked a user using GitHub's GET /user/blocks/:username API v3 endpoint.

    – Amadan
    Nov 13 '18 at 11:08












  • In gitLab, I can block users from admin area. once it's done, user will blocked in the platform and he can't connect with his account even he already pushed some commits. In this case, Jenkins shouldn't send emails any more for these blocked users

    – Imen
    Nov 13 '18 at 12:08











  • As I said, that's GitHub functionality, not git. The two are very different things.

    – Amadan
    Nov 13 '18 at 12:10






  • 1





    How could it be only on Github since I can do it from my Gitlab admin area ? Please check My edit, I added a screenshot to the functionality in Gitlab !

    – Imen
    Nov 13 '18 at 12:17











  • Ah, sorry, I misread. Then, it is your GitLab functionality (GitLab being a clone of GitHub, they have similar functions.) Not git.

    – Amadan
    Nov 13 '18 at 12:17








2




2





What do you mean, blocked authors? AFAIK, git has no concept of blocking. Are you mixing up git and GitHub? You can check whether you've blocked a user using GitHub's GET /user/blocks/:username API v3 endpoint.

– Amadan
Nov 13 '18 at 11:08






What do you mean, blocked authors? AFAIK, git has no concept of blocking. Are you mixing up git and GitHub? You can check whether you've blocked a user using GitHub's GET /user/blocks/:username API v3 endpoint.

– Amadan
Nov 13 '18 at 11:08














In gitLab, I can block users from admin area. once it's done, user will blocked in the platform and he can't connect with his account even he already pushed some commits. In this case, Jenkins shouldn't send emails any more for these blocked users

– Imen
Nov 13 '18 at 12:08





In gitLab, I can block users from admin area. once it's done, user will blocked in the platform and he can't connect with his account even he already pushed some commits. In this case, Jenkins shouldn't send emails any more for these blocked users

– Imen
Nov 13 '18 at 12:08













As I said, that's GitHub functionality, not git. The two are very different things.

– Amadan
Nov 13 '18 at 12:10





As I said, that's GitHub functionality, not git. The two are very different things.

– Amadan
Nov 13 '18 at 12:10




1




1





How could it be only on Github since I can do it from my Gitlab admin area ? Please check My edit, I added a screenshot to the functionality in Gitlab !

– Imen
Nov 13 '18 at 12:17





How could it be only on Github since I can do it from my Gitlab admin area ? Please check My edit, I added a screenshot to the functionality in Gitlab !

– Imen
Nov 13 '18 at 12:17













Ah, sorry, I misread. Then, it is your GitLab functionality (GitLab being a clone of GitHub, they have similar functions.) Not git.

– Amadan
Nov 13 '18 at 12:17






Ah, sorry, I misread. Then, it is your GitLab functionality (GitLab being a clone of GitHub, they have similar functions.) Not git.

– Amadan
Nov 13 '18 at 12:17













1 Answer
1






active

oldest

votes


















1














  • Go here (or rather, the equivalent setting on your private GitLab: User Settings > Access Tokens) and generate an access token with read_user permission. Be sure to copy it, or you'll never see it again (and you'll have to make a new one).



  • You can issue this command:



    curl -H "Private-Token: $token" "https://gitlab.com/api/v4/users/?username=$username"


    where $token is the token you created, and $username the GitLab username of the user you want to check. (Again, you will probably need to adjust the URL to match where your GitLab is, I don't think you're talking about gitlab.com here.) You can also search by email, using search=$email instead of username=$username.



    You will get a JSON. One of the fields is state, which can be active or blocked. You can use the jq utility, or any higher programming language, to parse the JSON and find the value of the state field.



    Alternately, you can append &active=true; this way, you get the user if he's unblocked, or an empty array () if blocked. This would be easier to test in bash, as you simply need to see if the result is "" or not. (You can also have the opposite test with &blocked=true to only return the user(s) if blocked.)



You can find the relevant documentation here.






share|improve this answer

























  • ok thank you, a clear idea and I will try it

    – Imen
    Nov 13 '18 at 13:32












  • it is ok for me thank you Amadan

    – Imen
    Nov 15 '18 at 12:38










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53279656%2fhow-to-get-only-unblocked-author-email-of-git-commit%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














  • Go here (or rather, the equivalent setting on your private GitLab: User Settings > Access Tokens) and generate an access token with read_user permission. Be sure to copy it, or you'll never see it again (and you'll have to make a new one).



  • You can issue this command:



    curl -H "Private-Token: $token" "https://gitlab.com/api/v4/users/?username=$username"


    where $token is the token you created, and $username the GitLab username of the user you want to check. (Again, you will probably need to adjust the URL to match where your GitLab is, I don't think you're talking about gitlab.com here.) You can also search by email, using search=$email instead of username=$username.



    You will get a JSON. One of the fields is state, which can be active or blocked. You can use the jq utility, or any higher programming language, to parse the JSON and find the value of the state field.



    Alternately, you can append &active=true; this way, you get the user if he's unblocked, or an empty array () if blocked. This would be easier to test in bash, as you simply need to see if the result is "" or not. (You can also have the opposite test with &blocked=true to only return the user(s) if blocked.)



You can find the relevant documentation here.






share|improve this answer

























  • ok thank you, a clear idea and I will try it

    – Imen
    Nov 13 '18 at 13:32












  • it is ok for me thank you Amadan

    – Imen
    Nov 15 '18 at 12:38















1














  • Go here (or rather, the equivalent setting on your private GitLab: User Settings > Access Tokens) and generate an access token with read_user permission. Be sure to copy it, or you'll never see it again (and you'll have to make a new one).



  • You can issue this command:



    curl -H "Private-Token: $token" "https://gitlab.com/api/v4/users/?username=$username"


    where $token is the token you created, and $username the GitLab username of the user you want to check. (Again, you will probably need to adjust the URL to match where your GitLab is, I don't think you're talking about gitlab.com here.) You can also search by email, using search=$email instead of username=$username.



    You will get a JSON. One of the fields is state, which can be active or blocked. You can use the jq utility, or any higher programming language, to parse the JSON and find the value of the state field.



    Alternately, you can append &active=true; this way, you get the user if he's unblocked, or an empty array () if blocked. This would be easier to test in bash, as you simply need to see if the result is "" or not. (You can also have the opposite test with &blocked=true to only return the user(s) if blocked.)



You can find the relevant documentation here.






share|improve this answer

























  • ok thank you, a clear idea and I will try it

    – Imen
    Nov 13 '18 at 13:32












  • it is ok for me thank you Amadan

    – Imen
    Nov 15 '18 at 12:38













1












1








1







  • Go here (or rather, the equivalent setting on your private GitLab: User Settings > Access Tokens) and generate an access token with read_user permission. Be sure to copy it, or you'll never see it again (and you'll have to make a new one).



  • You can issue this command:



    curl -H "Private-Token: $token" "https://gitlab.com/api/v4/users/?username=$username"


    where $token is the token you created, and $username the GitLab username of the user you want to check. (Again, you will probably need to adjust the URL to match where your GitLab is, I don't think you're talking about gitlab.com here.) You can also search by email, using search=$email instead of username=$username.



    You will get a JSON. One of the fields is state, which can be active or blocked. You can use the jq utility, or any higher programming language, to parse the JSON and find the value of the state field.



    Alternately, you can append &active=true; this way, you get the user if he's unblocked, or an empty array () if blocked. This would be easier to test in bash, as you simply need to see if the result is "" or not. (You can also have the opposite test with &blocked=true to only return the user(s) if blocked.)



You can find the relevant documentation here.






share|improve this answer















  • Go here (or rather, the equivalent setting on your private GitLab: User Settings > Access Tokens) and generate an access token with read_user permission. Be sure to copy it, or you'll never see it again (and you'll have to make a new one).



  • You can issue this command:



    curl -H "Private-Token: $token" "https://gitlab.com/api/v4/users/?username=$username"


    where $token is the token you created, and $username the GitLab username of the user you want to check. (Again, you will probably need to adjust the URL to match where your GitLab is, I don't think you're talking about gitlab.com here.) You can also search by email, using search=$email instead of username=$username.



    You will get a JSON. One of the fields is state, which can be active or blocked. You can use the jq utility, or any higher programming language, to parse the JSON and find the value of the state field.



    Alternately, you can append &active=true; this way, you get the user if he's unblocked, or an empty array () if blocked. This would be easier to test in bash, as you simply need to see if the result is "" or not. (You can also have the opposite test with &blocked=true to only return the user(s) if blocked.)



You can find the relevant documentation here.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 13 '18 at 12:42

























answered Nov 13 '18 at 12:35









AmadanAmadan

129k13140192




129k13140192












  • ok thank you, a clear idea and I will try it

    – Imen
    Nov 13 '18 at 13:32












  • it is ok for me thank you Amadan

    – Imen
    Nov 15 '18 at 12:38

















  • ok thank you, a clear idea and I will try it

    – Imen
    Nov 13 '18 at 13:32












  • it is ok for me thank you Amadan

    – Imen
    Nov 15 '18 at 12:38
















ok thank you, a clear idea and I will try it

– Imen
Nov 13 '18 at 13:32






ok thank you, a clear idea and I will try it

– Imen
Nov 13 '18 at 13:32














it is ok for me thank you Amadan

– Imen
Nov 15 '18 at 12:38





it is ok for me thank you Amadan

– Imen
Nov 15 '18 at 12:38

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53279656%2fhow-to-get-only-unblocked-author-email-of-git-commit%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

Museum of Modern and Contemporary Art of Trento and Rovereto