gvalkov / jenkins-autojobs

Automatically create Jenkins jobs from template jobs and branches in a SCM repository
http://jenkins-autojobs.rtfd.org
Other
49 stars 39 forks source link

Branch specifier to allow "origin/master" : using origin #40

Open stephaneerard opened 9 years ago

stephaneerard commented 9 years ago

Hello,

I need to specify «origin/$mybranch» as Branch Specifier. Anyone could tell me how to do that ?

Thank you very much  :)

gvalkov commented 9 years ago

Hello Stéphane,

If you're using an url for the value of the repo key, then the following should work:

refs:
    - refs/heads/$branch

Let me know if this answers your question.

Kind regards, Georgi

stephaneerard commented 9 years ago

Hello Georgi, I can help to write some docs too I guess ;)

I don't really understand what you mean by "url for the value of the repo key". The repo URL in the job template is a git@git.....git using Git SCM. I'm not at work so cannot try until monday.

Thank you very much for helping !

gvalkov commented 9 years ago

What jenkins-autojobs basically does is run a git ls-remote git@url.to/repo | awk '{print $2}'. This is what the output of that command looks like:

$ git ls-remote https://github.com/numpy/numpy.git | awk '{print $2}'
refs/heads/auto
refs/heads/enable_separate_by_default
refs/heads/maintenance/1.5.x
refs/heads/maintenance/1.6.x
refs/heads/master

If we wanted to create jobs for the master, auto and all maintenance branches, we would write the following refs section:

refs:
   - refs/heads/master
   - refs/heads/auto
   - refs/heads/maintenance/(.*)

It's quite straighforward - the regexes in the refs section are matched against the output of git ls-remote. I think the best source of information about this is the annotated git config file.

stephaneerard commented 9 years ago

Hllo Gerogi,

I've been able to test the $branch. Obviously I don't get it :)

Here is a screenshot of what I want : http://fr.tinypic.com/r/3586wwm/8

I want this because with current setup, Git SCM outputs this :

Started by user anonymous
Building remotely on PAR-DEV-JENKINS-SLAVE (vm docker-host) in workspace /home/jenkins/workspaces/workspace/FRONT-SEARCH-BRANCH-feature-ci
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url git@git.mycomp..ninja:front/search.git # timeout=10
Fetching upstream changes from git@git.mycomp..ninja:front/search.git
 > git --version # timeout=10
using GIT_SSH to set credentials 
 > git -c core.askpass=true fetch --tags --progress git@git.mycomp..ninja:front/search.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse feature/ci^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/feature/ci^{commit} # timeout=10
Multiple candidate revisions
Scheduling another build to catch up with FRONT-SEARCH-BRANCH-feature-ci
Checking out Revision 1991fc895ea4eb9540a51ea77bcb4380f8707e58 (feature/ci)

The

Scheduling another build to catch up with FRONT-SEARCH-BRANCH-feature-ci

Is what I want to avoid here.

Thank you !!