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

Checkout to wrong tag #45

Closed
bruliniko opened this Issue Oct 17, 2014 · 10 comments

Comments

Projects
None yet
4 participants
@bruliniko
Copy link

bruliniko commented Oct 17, 2014

Hi.

I'm having a problem with builds started by jenkins-gitlab-hook-plugin

Scenario:

gitlab tag push webhook is sent to jenkins instance

Branch Specifier is filled with wildcard expression [part of tag name]
when name is matched build start but git repo in workspace checks out to wrong commit

Am I doing something wrong or plugin doesn't support building from tags??

Cheers,
Dominik

@elvanja

This comment has been minimized.

Copy link
Owner

elvanja commented Oct 25, 2014

Hey @bruliniko, unfortunately you're right, the tags don't work at the moment.
Will be available in next release.
Thank you for reporting.

@elvanja elvanja added the enhancement label Oct 25, 2014

@javiplx

This comment has been minimized.

Copy link
Contributor

javiplx commented Oct 25, 2014

Your problem might get solved with #41. It works if you have a parametrized job (BRANCH_TO_BUILD), and set SCM branch specifier set to it (as stated in README). I have also modified the SCM branch specification to match only tags, and my PR takes that into account to build only when a tag is pushed, and not with normal pushes.

@elvanja

This comment has been minimized.

Copy link
Owner

elvanja commented Oct 25, 2014

Thanks @javiplx! @bruliniko, the #41 is now merged in master and will be available on next release.

I tried the following combinations to setup a job that would trigger on tag commits only:

  • refspec set to +refs/tags/:refs/remotes/origin/
  • parametrized
    • string parameter BRANCH_TO_BUILD
    • branch specifier set to origin/${BRANCH_TO_BUILD}
    • refspec set to +refs/tags/:refs/remotes/origin/
      Either works just fine, e.g. the correct tag and related commit are checked out and built.

There is an option that will not work by itself:

  • branch specifier set to origin/[tag prefix]**
    The idea is to match branch name of the tag. The problem is that the default refspec (e.g. if left empty) is +refs/heads/* so it doesn't match the tags at all. The solution is to put a correct refspec, but then you're back to the first option (mentioned above).

@elvanja elvanja closed this Oct 25, 2014

@timroes

This comment has been minimized.

Copy link

timroes commented Feb 16, 2015

This doesn't work for me somehow.

I think I've set up everything as you described, as you can see in the following screenshot.

Config

Also there is a string parameter with the name BRANCH_TO_BUILD In this task (which just didn't fit onto the screen anymore).

But the job is never triggered when you push a tag. Even thought Gitlab seems to be setup all right, since the tag notification is shown in the logs:

Logs

Any ideas, what could be broken? I tried several combinations of using ${ref} instead, and different branch specifiers, but nothing worked. Triggering plain push does work (without the refspec).

@javiplx

This comment has been minimized.

Copy link
Contributor

javiplx commented Feb 16, 2015

I had a setup similar to yours, and it worked as far as I remember. But I think i didn't prefix with origin on the branch specifier, and anyway I was using my own master branch.
I'm now using another approach, but will take a few weeks to get released. Basically, a TAGNAME variable is available on these cases, and refs/tags/${TAGNAME} can be used as branch specifier.

@timroes

This comment has been minimized.

Copy link

timroes commented Feb 17, 2015

I also tried not using origin/ but unfortunately that didn't help :-(

That other approach sounds very promising. Will there be an update to this jenkins plugin, that will incorporate these changes?

@javiplx

This comment has been minimized.

Copy link
Contributor

javiplx commented Feb 17, 2015

Although this change is not hard, it relies on other changes, so it will but not be soon. Let say probably a bit more than one month.

javiplx referenced this issue in jenkinsci/gitlab-hook-plugin Feb 23, 2015

Merge pull request #45 from javiplx/hardening/branch_matching
Hardening/branch matching

Conflicts:
	models/values/project.rb
	spec/values/project_spec.rb

Bundled commits:
	f3b9380 Don't prefix with remote name when simple branch names are configured on SCM
	6baf7db Allow proper matching if using refs style names for branch specifiers
	8082e25 Allow exact matches when configured branch starts with wildcard (Resolves #42)
@javiplx

This comment has been minimized.

Copy link
Contributor

javiplx commented Feb 25, 2015

I believe I've been able to remove dependencies on unreleased parts. You can try with
http://repo.jenkins-ci.org/snapshots/org/jenkins-ci/ruby-plugins/gitlab-hook/1.4.0-SNAPSHOT/
take into account that this will only work if you have a TAGNAME parameter on your job and set the branch specification to refs/tags/${TAGNAME}

@timroes

This comment has been minimized.

Copy link

timroes commented May 15, 2015

Might I ask, if this bug is fixed in the released 1.4.0 Version?

@javiplx

This comment has been minimized.

Copy link
Contributor

javiplx commented May 16, 2015

This is not exactly fixed, but 1.4.0 supports building of tags, using a different approach. Have a look at https://github.com/jenkinsci/gitlab-hook-plugin/#building-tags

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.