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

Trigger build or rebuild of non-head commit #241

Closed
wl2776 opened this issue Mar 21, 2016 · 6 comments
Closed

Trigger build or rebuild of non-head commit #241

wl2776 opened this issue Mar 21, 2016 · 6 comments

Comments

@wl2776
Copy link

wl2776 commented Mar 21, 2016

Sometimes our builds fail because of the Jenkins bug (https://issues.jenkins-ci.org/browse/JENKINS-9104). Jenkins offers "Rebuild" button, but if some more commits were pushed to that branch, this button triggers rebuilding them (head of the branch instead of specific SHA1 ID).

Same situation appears if we want to manually rebuild some specific repository snapshot, which is not on the head of any branch.

@omehegan
Copy link
Member

Any manual build that you trigger is going to use only the Git plugin to check out code. The gitlab plugin will not be a factor at all. If you're talking about manual builds here, this is not a bug in our plugin.

@wl2776
Copy link
Author

wl2776 commented Mar 22, 2016

Any manual build that you trigger is going to use only the Git plugin to check out code. The gitlab plugin will not be a factor at all.

This is incorrect. At least, the manual for the Gitlab plugin affects checkout. Here is how.

  1. I've got a failed build of a specific snapshot with known SHA1 ID that I want to rerun. I have "Parameterized Build" checked in the job settings, and the value of this parameter is assigned to the gitlabSourceBranch variable.
  2. I click on "Rebuild" link, and Jenkins offers me to enter build parameters (which is a single gitlabSourceBranch).
  3. I enter that SHA1 id instead of my branch name (say, 0a1231abc12311e401.... 40 characters in total)
  4. I have also configured Git plugin for the job, as described in Gitlab plugin manual. Please, note origin/${gitlabSourceBranch} in the description of the Branch specifier.
  5. And that configuration turns SHA1 id, that I've entered in step 3, into origin/0a1231abc12311e401....

Obviously, checkout fails.

Currently I've fixed the problem by simply removing origin/.

Conclusion.
Either the manual should be fixed, or some plugin (Git or Gitlab, I don't know) expects that origin/ is always prepended/always missing, and that behavior should be fixed somehow, or at least clearly described.

@omehegan
Copy link
Member

The parameter "gitlabSourceBranch" expects a branch name. You are passing it a SHA1 ID instead. That's why it is not working. This is not a bug in either plugin. If you want this to work, you would need to create an additional parameter for your job, called SHA1 or something, and have some logic within the job to have git check out origin/${gitlabSourceBranch} if that is populated, or check out SHA1 if that field is populated. And of course you will also need to catch the case where someone populates both fields :)

@wl2776
Copy link
Author

wl2776 commented Mar 23, 2016

Could you suggest me how I can add this logic?
Till now, I've seen only conditional build step plugin for jenkins, but it works after the code has been checked out.

@omehegan
Copy link
Member

@wl2776 it would have to be something like a Workflow/Pipeline style build. https://github.com/jenkinsci/workflow-plugin That would let you wrap some logic around the checkout step, which is otherwise impossible in other build types.

@wl2776
Copy link
Author

wl2776 commented Apr 2, 2016

@omehegan Thanks, I will keep it in mind that my current fix with removing origin/ from the Branch specifier violates plugin's expectations. But it currently works fine.

exceed-alae pushed a commit to exceed-alae/gitlab-plugin that referenced this issue May 20, 2022
When the build is scheduled, add an extension that will go back and cancel queued builds, and abort running builds.
Fixes jenkinsci#272 and fixes jenkinsci#241
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants