How to get ONLY unblocked author email of git commit
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
git jenkins jenkins-pipeline
|
show 1 more comment
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
git jenkins jenkins-pipeline
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'sGET /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
|
show 1 more comment
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
git jenkins jenkins-pipeline
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
git jenkins jenkins-pipeline
git jenkins jenkins-pipeline
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'sGET /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
|
show 1 more comment
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'sGET /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
|
show 1 more comment
1 Answer
1
active
oldest
votes
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, usingsearch=$email
instead ofusername=$username
.You will get a JSON. One of the fields is
state
, which can beactive
orblocked
. You can use thejq
utility, or any higher programming language, to parse the JSON and find the value of thestate
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.
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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, usingsearch=$email
instead ofusername=$username
.You will get a JSON. One of the fields is
state
, which can beactive
orblocked
. You can use thejq
utility, or any higher programming language, to parse the JSON and find the value of thestate
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.
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
add a comment |
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, usingsearch=$email
instead ofusername=$username
.You will get a JSON. One of the fields is
state
, which can beactive
orblocked
. You can use thejq
utility, or any higher programming language, to parse the JSON and find the value of thestate
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.
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
add a comment |
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, usingsearch=$email
instead ofusername=$username
.You will get a JSON. One of the fields is
state
, which can beactive
orblocked
. You can use thejq
utility, or any higher programming language, to parse the JSON and find the value of thestate
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.
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, usingsearch=$email
instead ofusername=$username
.You will get a JSON. One of the fields is
state
, which can beactive
orblocked
. You can use thejq
utility, or any higher programming language, to parse the JSON and find the value of thestate
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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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