Can a GitLab Webhook be stopped from triggering build in Jenkins
I have a GitLab project with a WebHook which triggers a Jenkins job. As of now, I have enabled Push Events to trigger the Jenkins job. So, whenever I push code from my local computer to remote repository, the Jenkins job is automatically triggered and the job successfully builds my codebase by checking out the code from GitLab's master branch.
Is there an option using which I can have the Webhook trigger Jenkins build only on such push events whose commit message contains a specified string like "build jenkins"?
I assume the answer to above to be No as the Webhook has already been configured and can't be stopped. However, I read slightly about creating custom hooks on the remote repository which can help me in above. If that is true, how can I do that and where do I need to write the custom hook and how to use it?
Thanks
jenkins gitlab webhooks git-webhooks
|
show 5 more comments
I have a GitLab project with a WebHook which triggers a Jenkins job. As of now, I have enabled Push Events to trigger the Jenkins job. So, whenever I push code from my local computer to remote repository, the Jenkins job is automatically triggered and the job successfully builds my codebase by checking out the code from GitLab's master branch.
Is there an option using which I can have the Webhook trigger Jenkins build only on such push events whose commit message contains a specified string like "build jenkins"?
I assume the answer to above to be No as the Webhook has already been configured and can't be stopped. However, I read slightly about creating custom hooks on the remote repository which can help me in above. If that is true, how can I do that and where do I need to write the custom hook and how to use it?
Thanks
jenkins gitlab webhooks git-webhooks
Are you using gitlab hook plugin ? You can read the commit message in webhook payload and decide to run your build or not. github.com/jenkinsci/gitlab-hook-plugin/blob/master/README.md
– ben5556
Nov 22 at 20:11
Thanks @ben5556. I had a quick look and looks like I am not using gitlab hook plugin build_now. Will try that out. However, what I wanted to know was that will this trigger the Jenkins job to start or not. Would it be like it will start the job and then read the commit message in webhook payload and abort the job or would it be like it will not start the job at all?
– letsbondiway
Nov 24 at 4:41
What I’d recommend is have a single job which is triggered by the gitlab hook and then trigger your actual job based on the commit message. You can also extend this to trigger any of your other jobs based on the repo, branch and commit message from which the webhook came.
– ben5556
Nov 24 at 6:01
1
We use a different plugin - Generic Webhook Trigger Plugin and it works great! Check it out wiki.jenkins.io/plugins/servlet/…
– ben5556
Nov 24 at 6:02
Perfect. That worked @ben5556. Thanks!
– letsbondiway
Nov 26 at 18:50
|
show 5 more comments
I have a GitLab project with a WebHook which triggers a Jenkins job. As of now, I have enabled Push Events to trigger the Jenkins job. So, whenever I push code from my local computer to remote repository, the Jenkins job is automatically triggered and the job successfully builds my codebase by checking out the code from GitLab's master branch.
Is there an option using which I can have the Webhook trigger Jenkins build only on such push events whose commit message contains a specified string like "build jenkins"?
I assume the answer to above to be No as the Webhook has already been configured and can't be stopped. However, I read slightly about creating custom hooks on the remote repository which can help me in above. If that is true, how can I do that and where do I need to write the custom hook and how to use it?
Thanks
jenkins gitlab webhooks git-webhooks
I have a GitLab project with a WebHook which triggers a Jenkins job. As of now, I have enabled Push Events to trigger the Jenkins job. So, whenever I push code from my local computer to remote repository, the Jenkins job is automatically triggered and the job successfully builds my codebase by checking out the code from GitLab's master branch.
Is there an option using which I can have the Webhook trigger Jenkins build only on such push events whose commit message contains a specified string like "build jenkins"?
I assume the answer to above to be No as the Webhook has already been configured and can't be stopped. However, I read slightly about creating custom hooks on the remote repository which can help me in above. If that is true, how can I do that and where do I need to write the custom hook and how to use it?
Thanks
jenkins gitlab webhooks git-webhooks
jenkins gitlab webhooks git-webhooks
asked Nov 22 at 19:33
letsbondiway
8310
8310
Are you using gitlab hook plugin ? You can read the commit message in webhook payload and decide to run your build or not. github.com/jenkinsci/gitlab-hook-plugin/blob/master/README.md
– ben5556
Nov 22 at 20:11
Thanks @ben5556. I had a quick look and looks like I am not using gitlab hook plugin build_now. Will try that out. However, what I wanted to know was that will this trigger the Jenkins job to start or not. Would it be like it will start the job and then read the commit message in webhook payload and abort the job or would it be like it will not start the job at all?
– letsbondiway
Nov 24 at 4:41
What I’d recommend is have a single job which is triggered by the gitlab hook and then trigger your actual job based on the commit message. You can also extend this to trigger any of your other jobs based on the repo, branch and commit message from which the webhook came.
– ben5556
Nov 24 at 6:01
1
We use a different plugin - Generic Webhook Trigger Plugin and it works great! Check it out wiki.jenkins.io/plugins/servlet/…
– ben5556
Nov 24 at 6:02
Perfect. That worked @ben5556. Thanks!
– letsbondiway
Nov 26 at 18:50
|
show 5 more comments
Are you using gitlab hook plugin ? You can read the commit message in webhook payload and decide to run your build or not. github.com/jenkinsci/gitlab-hook-plugin/blob/master/README.md
– ben5556
Nov 22 at 20:11
Thanks @ben5556. I had a quick look and looks like I am not using gitlab hook plugin build_now. Will try that out. However, what I wanted to know was that will this trigger the Jenkins job to start or not. Would it be like it will start the job and then read the commit message in webhook payload and abort the job or would it be like it will not start the job at all?
– letsbondiway
Nov 24 at 4:41
What I’d recommend is have a single job which is triggered by the gitlab hook and then trigger your actual job based on the commit message. You can also extend this to trigger any of your other jobs based on the repo, branch and commit message from which the webhook came.
– ben5556
Nov 24 at 6:01
1
We use a different plugin - Generic Webhook Trigger Plugin and it works great! Check it out wiki.jenkins.io/plugins/servlet/…
– ben5556
Nov 24 at 6:02
Perfect. That worked @ben5556. Thanks!
– letsbondiway
Nov 26 at 18:50
Are you using gitlab hook plugin ? You can read the commit message in webhook payload and decide to run your build or not. github.com/jenkinsci/gitlab-hook-plugin/blob/master/README.md
– ben5556
Nov 22 at 20:11
Are you using gitlab hook plugin ? You can read the commit message in webhook payload and decide to run your build or not. github.com/jenkinsci/gitlab-hook-plugin/blob/master/README.md
– ben5556
Nov 22 at 20:11
Thanks @ben5556. I had a quick look and looks like I am not using gitlab hook plugin build_now. Will try that out. However, what I wanted to know was that will this trigger the Jenkins job to start or not. Would it be like it will start the job and then read the commit message in webhook payload and abort the job or would it be like it will not start the job at all?
– letsbondiway
Nov 24 at 4:41
Thanks @ben5556. I had a quick look and looks like I am not using gitlab hook plugin build_now. Will try that out. However, what I wanted to know was that will this trigger the Jenkins job to start or not. Would it be like it will start the job and then read the commit message in webhook payload and abort the job or would it be like it will not start the job at all?
– letsbondiway
Nov 24 at 4:41
What I’d recommend is have a single job which is triggered by the gitlab hook and then trigger your actual job based on the commit message. You can also extend this to trigger any of your other jobs based on the repo, branch and commit message from which the webhook came.
– ben5556
Nov 24 at 6:01
What I’d recommend is have a single job which is triggered by the gitlab hook and then trigger your actual job based on the commit message. You can also extend this to trigger any of your other jobs based on the repo, branch and commit message from which the webhook came.
– ben5556
Nov 24 at 6:01
1
1
We use a different plugin - Generic Webhook Trigger Plugin and it works great! Check it out wiki.jenkins.io/plugins/servlet/…
– ben5556
Nov 24 at 6:02
We use a different plugin - Generic Webhook Trigger Plugin and it works great! Check it out wiki.jenkins.io/plugins/servlet/…
– ben5556
Nov 24 at 6:02
Perfect. That worked @ben5556. Thanks!
– letsbondiway
Nov 26 at 18:50
Perfect. That worked @ben5556. Thanks!
– letsbondiway
Nov 26 at 18:50
|
show 5 more comments
1 Answer
1
active
oldest
votes
Recommend using Generic Webhook Trigger Plugin - https://wiki.jenkins.io/display/JENKINS/Generic+Webhook+Trigger+Plugin
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%2f53437145%2fcan-a-gitlab-webhook-be-stopped-from-triggering-build-in-jenkins%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
Recommend using Generic Webhook Trigger Plugin - https://wiki.jenkins.io/display/JENKINS/Generic+Webhook+Trigger+Plugin
add a comment |
Recommend using Generic Webhook Trigger Plugin - https://wiki.jenkins.io/display/JENKINS/Generic+Webhook+Trigger+Plugin
add a comment |
Recommend using Generic Webhook Trigger Plugin - https://wiki.jenkins.io/display/JENKINS/Generic+Webhook+Trigger+Plugin
Recommend using Generic Webhook Trigger Plugin - https://wiki.jenkins.io/display/JENKINS/Generic+Webhook+Trigger+Plugin
answered Nov 30 at 5:17
ben5556
1,732139
1,732139
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f53437145%2fcan-a-gitlab-webhook-be-stopped-from-triggering-build-in-jenkins%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
Are you using gitlab hook plugin ? You can read the commit message in webhook payload and decide to run your build or not. github.com/jenkinsci/gitlab-hook-plugin/blob/master/README.md
– ben5556
Nov 22 at 20:11
Thanks @ben5556. I had a quick look and looks like I am not using gitlab hook plugin build_now. Will try that out. However, what I wanted to know was that will this trigger the Jenkins job to start or not. Would it be like it will start the job and then read the commit message in webhook payload and abort the job or would it be like it will not start the job at all?
– letsbondiway
Nov 24 at 4:41
What I’d recommend is have a single job which is triggered by the gitlab hook and then trigger your actual job based on the commit message. You can also extend this to trigger any of your other jobs based on the repo, branch and commit message from which the webhook came.
– ben5556
Nov 24 at 6:01
1
We use a different plugin - Generic Webhook Trigger Plugin and it works great! Check it out wiki.jenkins.io/plugins/servlet/…
– ben5556
Nov 24 at 6:02
Perfect. That worked @ben5556. Thanks!
– letsbondiway
Nov 26 at 18:50