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

Empty Filter Branches Select Box #58

Closed
LaoArchAngel opened this issue Feb 19, 2015 · 24 comments
Closed

Empty Filter Branches Select Box #58

LaoArchAngel opened this issue Feb 19, 2015 · 24 comments

Comments

@LaoArchAngel
Copy link

Filter branches select box never gets populated with the branches from a project.

Here’s my setup:

Single (non-clustered) Jenkins and GitLab servers.
GitLab v. 7.7.8 (on
Jenkins v. 1.588 (on Windows Server 2014)
GIT client plugin 1.16.1
GIT plugin 2.3.5
GitHub Plugin 1.10
GitLab Plugin 1.1.14

In my global Jenkins configuration, I have set the GitLab section as follows:
Gitlab host URL = http://gitlab.our.domain (I have also tried the IP address for all gitlab.our.domain)
API Token = (Set)
Ignose SSL Certificate Errors = (Checked)
Test Connection = Success when clicked

In my project configuration, I have as follows:
GitHub project = http://gitlab.our.domain/GroupName/ProjectName/
Git Repository URL = [email protected]:GroupName/ProjectName.git
Credentials = (ssh key set)
Name = origin
Repository browser = gitlab
URL = http://gitlab.our.domain/GroupName/ProjectName
Version = 7.7

Build when a change is pushed to Gitlab. = (Checked)
Build on Push Events = (Checked)
Set build description to build cause = (Checked)
Add note with build status on merge requests = (Checked)
Filter branches = (Blank)

I have saved and reloaded the configuration.
I have set up the GitLab CI settings on GitLab. Clicking the Test settings button triggers a build successfully.
The build can reach gitlab, pull, clone, and build.
The only thing that does not appear to be working is the Filter branches box.

I don't know if I should be looking for logs somewhere. I would love to debug this myself, but this would be my first jenkins plugin debugging venture and I don't think I have the bandwidth for the learning curve.

@bassrock
Copy link
Contributor

@LaoArchAngel what is the user level of the api key that you used in gitlab?

@LaoArchAngel
Copy link
Author

Admin for our GitLab installation. I don't think the user is a member of
some of these projects, but the projects are set to internal, so the user
should be able to discover, clone and fetch. I will try adding the user as
a member of the repositories and report back.

On Thu, Feb 19, 2015 at 11:44 AM, bassrock [email protected] wrote:

@LaoArchAngel https://github.com/LaoArchAngel what is the user level of
the api key that you used in gitlab?


Reply to this email directly or view it on GitHub
#58 (comment)
.

@LaoArchAngel
Copy link
Author

I have now tried setting the user as a master of a repository with a jenkins job, changed the API key in global jenkins config to the owner of the gitlab repository (my API key), saved, triggered the build, still empty.

@bassrock
Copy link
Contributor

@LaoArchAngel if you look at the gitter chat, it looks like some have reported this an issue with the permissions required by gitlab and it being set to internal.

@LaoArchAngel
Copy link
Author

@bassrock Sorry for the late response. I tried changing the project to Public visibility. The branch list is still empty. Read / searched gitter chat, but none of the suggestions there helped.

@JaSei
Copy link

JaSei commented Apr 1, 2015

Hi, I have same problem
Jenkins ver. 1.606 (Windows 7 host)
gitlab GitLab 7.8.4

jenkins user have right's developer (but I try change to master, owner and nothing)
some next ideas what is bad?

thx

@bassrock
Copy link
Contributor

@LaoArchAngel or @JaSei can you provide some logs?

@LaoArchAngel
Copy link
Author

I may be able to. Can you guide me on where to get the logs you need? Would
I have to change log verbosity somewhere?
On Apr 13, 2015 11:30 AM, "bassrock" [email protected] wrote:

@LaoArchAngel https://github.com/LaoArchAngel or @JaSei
https://github.com/JaSei can you provide some logs?


Reply to this email directly or view it on GitHub
#58 (comment)
.

@bassrock
Copy link
Contributor

go to JENKINSHOST/log and create a new logger with a high verbosity level.

@JaSei
Copy link

JaSei commented Apr 16, 2015

In log doesn't nothing on this...
If I open configuration of job - nothing new in log...
If I save configuration of job, then:

ScavengerFeeder2-deploy #100 main build action completed: SUCCESS
Dub 16, 2015 9:01:47 DOP. WARNING org.kohsuke.stapler.RequestImpl$TypePair convertJSON
'stapler-class' is deprecated: hudson.tasks.LogRotator
Dub 16, 2015 9:01:47 DOP. WARNING org.kohsuke.stapler.RequestImpl$TypePair convertJSON
'stapler-class' is deprecated: hudson.plugins.git.extensions.impl.PreBuildMerge
Dub 16, 2015 9:01:47 DOP. WARNING org.kohsuke.stapler.RequestImpl$TypePair convertJSON
'stapler-class' is deprecated: hudson.tasks.Shell
Dub 16, 2015 9:01:47 DOP. WARNING org.kohsuke.stapler.RequestImpl$TypePair convertJSON
'stapler-class' is deprecated: hudson.tasks.Mailer

@notmandatory
Copy link

I'm having the same issue. Did anyone find a solution? If you still need logs let me know which ones you need. Thanks!

@valloq
Copy link

valloq commented May 11, 2015

Looking for a solution to this as well. This is currently stopping us from specifying a production/deployment build in Jenkins.

@maiksensi
Copy link

We are suffering from the same problem. Funny thing though, with one Jenkins (host on Windows) it works, and with one (Linux) it doesnt.

UPDATE: We actually found the problem, which was pretty trivial. We added Jenkins as a reporter, but not with the actual repository but rather with the Project (which contains different repositories). After ading Jenkins as a reporter on the repository it started to work.

@mirupal
Copy link

mirupal commented Jun 8, 2015

Same here.

  • GitLab 6.8.2
  • Jenkins ver. 1.609.1 (Ubuntu 14.04)

@WonderCsabo
Copy link
Contributor

I am also experiencing this.

  • GitLab 7.9.2
  • Jenkins ver. 1.609

Edit: I just realized, this feature is not what i am looking for. I want to add a list of disallowed branches. This list supposed to contain the allowed branches. Is there any way to achieve what i want? (Real case: i want to build all branches except master.)

@klausbayrhammer
Copy link

Same problem here

Gitlab-Plugin 1.1.16
Jenkins: 1.596.2
Gitlab: 7.9.1

@klausbayrhammer
Copy link

Is it possible, that the filtered-branches box only works when using key-based auth? I switched the checkout form username/password to ssh-keys and now it works.

@ghost
Copy link

ghost commented Jul 10, 2015

@amoreno-Cafpower
Copy link

I have the same problem:

Single (non-clustered) Jenkins and GitLab servers.
GitLab v. 7.8.4 (on
Jenkins v. 1.622
GIT client plugin 1.18.0
GIT plugin 2.4.0
GitLab Plugin 1.1.25

In my global Jenkins configuration, I have set the GitLab section as follows:
Gitlab host URL = http://gitlab.our.domain (I have also tried the IP address for all gitlab.our.domain)
API Token = (Set)
Ignose SSL Certificate Errors = (Checked)
Test Connection = Success when clicked

In my project configuration, I have as follows:
GitHub project = http://gitlab.our.domain/GroupName/ProjectName/
Git Repository URL = [email protected]:GroupName/ProjectName.git
Credentials = (none)
Repository browser = gitlab
URL = http://gitlab.our.domain/GroupName/ProjectName
Version = 7.8

Build when a change is pushed to Gitlab. = (Checked)
Build on Push Events = (Checked)
Set build description to build cause = (Checked)
Add note with build status on merge requests = (Checked)
Filter branches = (Blank)

@joshtkehoe
Copy link

I had this problem as well and here is how I solved it - though it appears that this may be caused by many different things.

I followed the instructions as specified here, but still did not work: http://stackoverflow.com/questions/31339318/jenkins-filter-branches-empty/31341937#31341937

My build's repository URL was using SSH with 'None' selected for Credentials. I changed this to our HTTPS URL with a GitLab user's credentials with a 'Developer' role (though 'Reporter' may also work), and saved the job. I then had to leave the job configuration page and come back and the list was populated.

This may be all most of you need to do, but our preferred method of authentication is SSH, so I next updated the job setting it back to SSH without credentials and saved it. Leaving the job and coming back in shows the box is now empty again, however, looking at the job's config.xml, the branch setting is still selected and is being used. Or, for that matter, you could probably just modify the config.xml directly by updating the <allowedBranches> element (example below).

  <triggers>
    <com.dabsquared.gitlabjenkins.GitLabPushTrigger plugin="[email protected]">
      <spec></spec>
      <triggerOnPush>true</triggerOnPush>
      <triggerOnMergeRequest>false</triggerOnMergeRequest>
      <triggerOpenMergeRequestOnPush>true</triggerOpenMergeRequestOnPush>
      <ciSkip>true</ciSkip>
      <setBuildDescription>true</setBuildDescription>
      <addNoteOnMergeRequest>true</addNoteOnMergeRequest>
      <addVoteOnMergeRequest>true</addVoteOnMergeRequest>
      <allowAllBranches>false</allowAllBranches>
      <allowedBranches>
        <string>trunk</string>
        <string>whatever-branch</string>
      </allowedBranches>
    </com.dabsquared.gitlabjenkins.GitLabPushTrigger>
  </triggers>

@WonderCsabo
Copy link
Contributor

After updating to the latest version, there is no selector box, but a textfield. This field accepts a comma-separated list of branches to be built. (Also there is a similar exclude field).
I added my branch, and it says the branch cannot be found, but works regardless.

So i guess this was fixed by e47e81c ?

@ghost
Copy link

ghost commented Feb 9, 2016

Hi,
As my contribution to this project I'd like to tell the story of my struggle with this problem. I hope that it will help others to handle it.

At the beginning you have to be shure that you properly set your Jenkins user's account token in global settings. This is because plugin uses GitLab REST API to communicate with GitLab.
You can check that the communication is ok by running i.e.:

curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/user" 

If succeed, the plugin can freely use GitLab API.

The plugin to fetch the available branches do not use anything like git branch -a. It uses the API.

While the documentation does not tell explicitly that you can use the project name as an Id, plugin does not yet use /repository/branches. Plugin needs to find out the project Id.

To achieve that plugin fetches list of all projects and tries to find out with is the one. To do this plugin does not use /projects/all. There is called the /projects

At this stage this is very important to properly configure the Jenkins user. It doesn't matter that user has the admin privileges. The project must be accessible by the Jenkins user. User have to be a member of a group or member of the project or project must be public. And this is probably the place you failed.

To see the list of projects accessible by the user try:

curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects"` 

The next step is to find the project. It seems that the only information available to distinguish the projects is the source repository url. So pugin compares the ssh_url_to_repo and http_url_to_repo fields from project object with the source repository url. This must be the exact match. And this is probably the place you failed.

For example if you uses only VPN for SSH connections, and you have to place the IP address as source repository url it will fail.

Few examples that works with git but not with a plugin:

And finally after then plugin uses the project id to call /repository/branches

I hope that this was helpful.

CC: @LaoArchAngel @JaSei @stevemyers @valloq @mirupal @WonderCsabo @klausbayrhammer @amorenopl @joshtkehoe

@ghost
Copy link

ghost commented Feb 26, 2016

@omehegan: I was going to write a fix for this issue... ;)

@omehegan
Copy link
Member

@pwl89 oh, I thought it was fixed already. If not, I will reopen.

exceed-alae pushed a commit to exceed-alae/gitlab-plugin that referenced this issue May 20, 2022
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