Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Jobs not matching branch regex are deleted #21

Open
eproxus opened this issue Jul 19, 2012 · 6 comments
Open

Jobs not matching branch regex are deleted #21

eproxus opened this issue Jul 19, 2012 · 6 comments
Labels

Comments

@eproxus
Copy link

eproxus commented Jul 19, 2012

When using -DbranchNameRegex=feature\/.+ as branch matching expression, branches named something else are deleted. I would expect only branches matching branchNameRegex would be created and deleted.

For example, if a template job exists named myproj-build-master and the branch regex is set to feature\/.+, then a manually created job named myproj-build-release is deleted.

@tednaleid
Copy link
Contributor

If that's the behavior that's happening, I agree that it's a bug. I won't have time to look at it till this weekend, but will test and fix any issues then.

tednaleid added a commit that referenced this issue Aug 10, 2012
@tednaleid
Copy link
Contributor

Sorry about the delay getting back to this. I could be missing something, but I'm not able to reproduce the behavior that you're seeing. I've added a test (referenced in the above commit, 7b849d1) that uses the regex filter that you're specifying and it does do the filter appropriately only down to those branches that start with feature/.

If I change the filter to something else, like feature2/.+, no branches come through.

If you run it with the -DprintConfig=true flag set, to print out your configuration in the log, is your switch getting passed through appropriately for the way you're running it? Another thing to try would be to put a println in the GitApi.getBranchNames method to see what the branchNameFilter regex is and why it's getting a true for the passesFilter check.

@eproxus
Copy link
Author

eproxus commented Aug 10, 2012

Thanks for taking your time to look at this!

The branch we had was actually called only branchname and not xxx/branchname if that is significant? I'll test out the behavior once more and see if I can reproduce it.

@eproxus
Copy link
Author

eproxus commented Aug 10, 2012

I just tried it out and I can reproduce with a job named myprefix-build-somethingelse:

Deleting deprecated jobs:
        myprefix-build-somethingelse

The job that jenkins-build-per-branch is using as template is named myprefix-build-master and our feature branch jobs are named myprefix-build-feature_xxx_xxx (based on branches named feature/xxx_xxx).

Maybe I'm missing something in the documentation that branches named myprefix-build-somethingelse are not allowed?

@alexmordue
Copy link

It seems to delete jobs based on the prefix you give it rather than the whole regex including branch name. In my set up I found that jobs with the same prefix were deleted even though the regex didn't match the job name.

@bedge
Copy link

bedge commented Oct 15, 2014

This has bitten me too. If I remove "release" from:
-DbranchNameRegex="feature/.+|hotfix/.+|release/.+"
to get
-DbranchNameRegex="feature/.+|hotfix/.+"

thinking that I'd like it to ignore the release branches, because they are precious and I'd like to always keep them around, but instead, it deletes them all. - exactly what I did not want to happen.

A serious WTF moment.

@jamesdh jamesdh added the Bug label Jun 28, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants