Giter VIP home page Giter VIP logo

jenkins-build-per-branch's Introduction

jenkins-build-per-branch's People

Contributors

asavoy avatar beckje01 avatar brantb avatar ebakke avatar jamesdh avatar jimmyw avatar sheehan avatar tednaleid avatar willdurand avatar yonatanp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jenkins-build-per-branch's Issues

Add a way to execute a script upon job deletion

This would be super useful to cleanup anything that has been created externally to jenkins eg pull down a VM.

All that would be required is a parameter for a script that gets executed together with a job name as a parameter.

When using GitHub authentication the gradle calls get a 403

When you use GitHub as an authentication platform, the calls end up witha 403.

[workspace] $ /var/lib/jenkins/jobs/SyncCrawljaxGitBranchesWithJenkins/workspace/gradlew -DjenkinsUrl=http://jenkins.crawljax.com -DgitUrl=git://github.com/crawljax/crawljax.git -DtemplateJobPrefix=crawljax -DtemplateBranchName=master -DnestedView=Crawljax-branches syncWithRepo
:compileJava UP-TO-DATE
:compileGroovy UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:syncWithRepo
===============================================================
 jenkinsUrl: http://jenkins.crawljax.com
 gitUrl: git://github.com/crawljax/crawljax.git
 templateJobPrefix: crawljax
 templateBranchName: master
 nestedView: Crawljax-branches
===============================================================
executing command: git ls-remote --heads git://github.com/crawljax/crawljax.git
    209f69659e82f24131a2e7c7405231615bfa1db8    refs/heads/better-xpath-resolving
    4fa9f2958cae6703a8a07ef9b8334500ebc57e70    refs/heads/blue-monday-master
    e865cf822a7fa3d22812700e504d1f7bfda214f8    refs/heads/fix-plugin-executions
    5af558824b2f3fd43e18a52b9c2e13ae5e9bd9de    refs/heads/js-updates
    01e2e696261d91222b2325200f0ead45cb3839cf    refs/heads/master
    8bc350f78bcc65a5e6952159735b4e43be7feca4    refs/heads/meaningful-statenames
    fb0b6bfec024389334b20c61d91315d58ca2fbbe    refs/heads/new-concurrency-squashed
    09551514995f46cedabd8c37af8da7b76c1ca51a    refs/heads/web-ui-stable
getting project names from http://jenkins.crawljax.com/api/json
Creating missing job: crawljax-fullbuild-better-xpath-resolving from crawljax-fullbuild-master
Exception in thread "main" java.lang.Exception: Unexpected failure with path http://jenkins.crawljax.com/job/crawljax-fullbuild-master/config.xml, HTTP Status Code: 403, full map: [path:job/crawljax-fullbuild-master/config.xml, contentType:text/plain, headers:[Accept:application/xml]]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
    at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:71)
    at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:81)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:54)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:194)
    at com.entagen.jenkins.JenkinsApi.get(JenkinsApi.groovy:148)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:267)
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:52)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
    at com.entagen.jenkins.JenkinsApi.getJobConfig(JenkinsApi.groovy:49)
    at com.entagen.jenkins.JenkinsApi$getJobConfig.callCurrent(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
    at com.entagen.jenkins.JenkinsApi.configForMissingJob(JenkinsApi.groovy:71)
    at com.entagen.jenkins.JenkinsApi$configForMissingJob.callCurrent(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:145)
    at com.entagen.jenkins.JenkinsApi.cloneJobForBranch(JenkinsApi.groovy:55)
    at com.entagen.jenkins.JenkinsApi$cloneJobForBranch.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
    at com.entagen.jenkins.JenkinsJobManager.createMissingJobs(JenkinsJobManager.groovy:64)
    at com.entagen.jenkins.JenkinsJobManager$createMissingJobs.callCurrent(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
    at com.entagen.jenkins.JenkinsJobManager.syncJobs(JenkinsJobManager.groovy:52)
    at com.entagen.jenkins.JenkinsJobManager$syncJobs.callCurrent(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
    at com.entagen.jenkins.JenkinsJobManager.syncWithRepo(JenkinsJobManager.groovy:39)
    at com.entagen.jenkins.JenkinsJobManager$syncWithRepo.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
    at com.entagen.jenkins.Main.main(Main.groovy:29)
Caused by: groovyx.net.http.HttpResponseException: Forbidden
    at groovyx.net.http.RESTClient.defaultFailureHandler(RESTClient.java:240)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1047)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:914)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:877)
    at groovy.lang.Closure.call(Closure.java:412)
    at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:508)
    at groovyx.net.http.RESTClient.get(RESTClient.java:118)
    at groovyx.net.http.RESTClient$get.call(Unknown Source)
    at com.entagen.jenkins.JenkinsApi.get(JenkinsApi.groovy:139)
    ... 40 more

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':syncWithRepo'.
> Command '/usr/lib/jvm/java-7-openjdk-i386/bin/java' finished with (non-zero) exit value 1.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 10.778 secs
Build step 'Invoke Gradle script' changed build result to FAILURE
Build step 'Invoke Gradle script' marked build as failure
Finished: FAILURE

Create jobs for a PR if no branch exists for said PR

We should auto-duplicate any jenkins jobs when a PR is submitted just as we do for ordinary branches. This would allow for a more open means of change submissions while still retaining the benefits of build-per-branch. Jenkins would report automatically if the PR submitted regresses (which we could have used already it seems)

Need a bit more control over git branch name propagation

We use the branch name in artifact filenames. This works fine for develop, release, etc.
But when a branch has a / in it, ie: release/bugless, it breaks things because it adds a / into the filename.

I'd like to have a way to specify the branch suffix, ie: bugless, rather than always replacing all tokens with the full branch name.
Not sure exactly how one would do this with the current architecture.

Perhaps, allow a regex replacement for string parameters so that one could tie a regex replace to specific parameters to control their expansion?

NullPointerException while dryrunning and generating branches

Hello,

I'm getting the following exception:

Exception in thread "main" java.lang.NullPointerException: Cannot invoke method contains() on null object
    at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:32)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at com.entagen.jenkins.JenkinsJobManager$_syncViews_closure7.doCall(JenkinsJobManager.groovy:116)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:901)

that makes the build fail. The exception gets printed somewhere in between the XML info of the builds,

Could you please support?

Thanks,

Branches with a suffix of templateBranchName will create a new, valid job template. Then creates many new jobs.

A newly pushed branch with the right name, will cause the script to auto-create a new job which would also matches the naming requirements for a "job template". Thus the script thinks a new job template exists, and the next time it is called, will create a new set of jobs, one for each existing branch, using the new (and invalid) job template.

I have set up the script with these parameters:

  • templateJobPrefix: MyProject
  • templateBranchName: master
  • one job template: MyProject-runTests-master

Then I pushed up a new branch judo-master.

This creates a new job, MyProject-runTests-judo-master.

Then the second time the script is called, I will see MyProject-runTests-judo-mybranch and more, with the base job name being MyProject-runTests-judo-.

Suggested fix

In line 93 of JenkinsJobManager.groovy, the regex used implicitly assumes that the - delimiter is not possible in a branch name. It's probably easiest to simply force - to not be accepted inside the middle 'jobName' section.

So change

String regex = /^($templateJobPrefix-.*)-($templateBranchName)$/` 

to

String regex = /^($templateJobPrefix-[^-]*)-($templateBranchName)$/

Too "loose" regex in nested views

When nested views are created for the new branches, the regex used for each listview is project.*branch. But if you have two branches where one ends with the same as the other is called the regex will get too many jobs.

Consider we have a branch stuff and another called new_stuff in our project abc. When jobs are generated the jobs will be called abc-xxx-stuff and abc-xxx-new_stuff, but the view for stuff will also contain the new_stuff jobs as the regex for that view will be abc.*stuff. So the same problem would occur if you had a project called abcdef, since abc is the first part.

I think a solution would be just to add hyphens to the regex: project-.*-branch.

Could not find method groovy() for arguments [org.codehaus.groovy:groovy-all:1.8.8] on root project

Followed your guide here but got this exception:

[workspace] $ /var/lib/jenkins/tools/hudson.plugins.gradle.GradleInstallation/Gradle_2.0/bin/gradle -DjenkinsUrl=http://localhost:8080/jenkins -DgitUrl=git+ssh://[email protected]/home/xxx/git/repos/maven-dummy.git -DtemplateJobPrefix=MyDummy -DtemplateBranchName=master -DnestedView=MyDummy-branches -DdryRun=true syncWithRepo

FAILURE: Build failed with an exception.

* Where:
Build file '/data/jenkins/jobs/SyncDummyGitBranchesWithJenkins/workspace/build.gradle' line: 9

* What went wrong:
A problem occurred evaluating root project 'workspace'.
> Could not find method groovy() for arguments [org.codehaus.groovy:groovy-all:1.8.8] on root project 'workspace'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 3.806 secs
Build step 'Invoke Gradle script' changed build result to FAILURE
Build step 'Invoke Gradle script' marked build as failure
Finished: FAILURE

This is using:

  • Jenkins 1.572
  • Gradle Plugin 1.24 (added Gradle 2.0 installation)
  • GIT Plugin 2.2.4
  • jenkins-build-per-branch from master

Any ideas?

Script silently fails when Jenkins' CSRF option is enabled

When Jenkins' "Prevent Cross Site Request Forgery exploits" option is enabled, POST actions performed by the script silently fail. (GET requests work fine.)

This happens even when all other security options are entirely disabled.

Sample output:

executing command: git ls-remote --heads ../repo
        9f3c8f2e99d41361fc2cf7188fa5fd4254a72385        refs/heads/production
        9060224e30ca142e39708f7285e8c1bd49608c92        refs/heads/stage
        56ade2ad39b76671b36f1c7944d418648f4ccdd2        refs/heads/test-qa
getting project names from http://jenkins:9000/api/json
Creating missing job: ProjectName-RunTests-production from ProjectName-RunTests-JobTemplate
Unexpected failure on http://jenkins:9000/createItem: HTTP/1.1 403 Forbidden 403
Unexpected failure on http://jenkins:9000/job/ProjectName-RunTests-production/config.xml: HTTP/1.1 403 Forbidden 403
Creating missing job: ProjectName-RunTests-stage from ProjectName-RunTests-JobTemplate
Unexpected failure on http://jenkins:9000/createItem: HTTP/1.1 403 Forbidden 403
Unexpected failure on http://jenkins:9000/job/ProjectName-RunTests-stage/config.xml: HTTP/1.1 403 Forbidden 403
getting views - nestedWithinView:null at path: api/json
Missing views: [ProjectName-production, ProjectName-stage]
creating view - viewName:ProjectName-production, nestedView:null
Unexpected failure on http://jenkins:9000/createView: HTTP/1.1 403 Forbidden 403
configuring view ProjectName-production
Unexpected failure on http://jenkins:9000/view/ProjectName-production/configSubmit: HTTP/1.1 403 Forbidden 403
creating view - viewName:ProjectName-stage, nestedView:null
Unexpected failure on http://jenkins:9000/createView: HTTP/1.1 403 Forbidden 403
configuring view ProjectName-stage
Unexpected failure on http://jenkins:9000/view/ProjectName-stage/configSubmit: HTTP/1.1 403 Forbidden 403
Deprecated views: []

BUILD SUCCESSFUL

Total time: 7.619 secs                                                                                        

:syncWithRepo FAILED

I'm simply following the tutorial to setup the project. And I got stuck and syncWithRepo task. Attached the error log. I don't know what went wrong...

getting views - nestedWithinView:MyProject at path: view/MyProject/api/json
Missing views: []
Exception in thread "main" java.lang.NullPointerException: Cannot invoke method minus() on null object
at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:32)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.entagen.jenkins.JenkinsJobManager.getDeprecatedViewNames(JenkinsJobManager.groovy:132)
at com.entagen.jenkins.JenkinsJobManager$getDeprecatedViewNames.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:145)
at com.entagen.jenkins.JenkinsJobManager.syncViews(JenkinsJobManager.groovy:119)
at com.entagen.jenkins.JenkinsJobManager$syncViews.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
at com.entagen.jenkins.JenkinsJobManager.syncWithRepo(JenkinsJobManager.groovy:43)
at com.entagen.jenkins.JenkinsJobManager$syncWithRepo.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
at com.entagen.jenkins.Main.main(Main.groovy:29)
:syncWithRepo FAILED

FAILURE: Build failed with an exception.

Error 403 (forbidden) if security is enabled

Hi,

I'm wondering if you could add user/apitoken fields for the plugin to be able to autenticate itself and run when jenkins uses security like Role-Based Strategy.

I'm getting this error and an exception:

Exception in thread "main" java.lang.Exception: Unexpected failure with path http://localhost:8080/api/json, HTTP Status Code: 403, full map: [path:api/json]
...

https://wiki.jenkins-ci.org/display/JENKINS/Authenticating+scripted+clients

Thanks in advance!

Fails with MissingMethodException

Exception in thread "main" groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.findResults() is applicable for argument types: (com.entagen.jenkins.JenkinsJobManager$_findRequiredTemplateJobs_closure5) values: [com.entagen.jenkins.JenkinsJobManager$_findRequiredTemplateJobs_closure5@d964af]
Possible solutions: findResult(groovy.lang.Closure), findResult(groovy.lang.Closure), findResult(java.lang.Object, groovy.lang.Closure), findResult(java.lang.Object, groovy.lang.Closure)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:54)
at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
at com.entagen.jenkins.JenkinsJobManager.findRequiredTemplateJobs(JenkinsJobManager.groovy:92)
at com.entagen.jenkins.JenkinsJobManager$findRequiredTemplateJobs.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
at com.entagen.jenkins.JenkinsJobManager.syncWithRepo(JenkinsJobManager.groovy:33)
at com.entagen.jenkins.JenkinsJobManager$syncWithRepo.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at com.entagen.jenkins.Main.main(Main.groovy:26)

FAILURE: Build failed with an exception.

Not requiring something in the middle between prefix and branch name

I want to be able to create job with prefix that is almost the same as the job name (minus the branch name).
My job name is ThisIsMyWholeJobNameAndAlsoMyPrefix-master

Exception in thread "main" java.lang.AssertionError: Unable to find any jobs matching template regex: ^(ThisIsMyWholeJobNameAndAlsoMyPrefix-[^-]*)-(master)$
You need at least one job to match the templateJobPrefix and templateBranchName suffix arguments. Expression: (templateJobs?.size() > 0)
    at org.codehaus.groovy.runtime.InvokerHelper.assertFailed(InvokerHelper.java:388)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.assertFailed(ScriptBytecodeAdapter.java:658)
    at com.entagen.jenkins.JenkinsJobManager.findRequiredTemplateJobs(JenkinsJobManager.groovy:108)
    at com.entagen.jenkins.JenkinsJobManager$findRequiredTemplateJobs.callCurrent(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
    at com.entagen.jenkins.JenkinsJobManager.syncWithRepo(JenkinsJobManager.groovy:37)
    at com.entagen.jenkins.JenkinsJobManager$syncWithRepo.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
    at com.entagen.jenkins.Main.main(Main.groovy:30)```

Downstream builds are updating with correct project name

This a great tool.

I have setup a series of downstream projects, A -> B -> C -> D.

All three projects are correctly created with a branch, A', B', C', and D', except that they are connected like so,
A' -> B' -> C -> D

I'm using the Parameterized Trigger Plugin, with Trigger/call builds on other projects during execution and post build, primarily to pass in environmental variables between jobs.

Thank you

If your branch name isn't prefixed with "origin/" in your job, it's not getting replaced

Bug report from Titas Norkunas:

See all_projects.png:

  1. this is template
  2. This is specific job that was run (one of the correctly fetched
    remote branches)

Now check out project_config.png:

  1. title is correct, using branch name
  2. why is it building master branch?

Btw documentation is pretty clear, was able to setup so far without
much confusion (ah, it was not transparent what to do with gradle for
me, I installed plugin and did apt-get, but then it was failing, so I
just used "wrapper" option and symlinked gradlew to
/opt/gradle/bin/gradle). But I am new to jenkins, for people who use
jenkins it might be obvious that after installing plugin they need to
go to manage jenkins and configure gradle there

Attached png files show that the job isn't getting the branch name properly replaced, after some digging I found that we're expecting the branch name to start with "origin/" in our code. This should be refactored from this:

config = config.replaceAll(">origin/${templateJob.templateBranchName}<", ">origin/${missingJob.branchName}<")

to something that replaces either if the branch name has a "/" or a ">" to it's left (and still has a "<" on the right).

On Windows Slave Gradle cannot execute git (git.cmd)

executing command: git ls-remote --heads git@myserver:repo.git
Exception in thread "main" java.io.IOException: Cannot run program "git": CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
    at java.lang.Runtime.exec(Runtime.java:593)
    at java.lang.Runtime.exec(Runtime.java:431)
    at java.lang.Runtime.exec(Runtime.java:328)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.execute(DefaultGroovyMethods.java:11431)
    at org.codehaus.groovy.runtime.dgm$218.invoke(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
    at com.entagen.jenkins.GitApi.eachResultLine(GitApi.groovy:34)
    at com.entagen.jenkins.GitApi$eachResultLine.callCurrent(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:145)
    at com.entagen.jenkins.GitApi.getBranchNames(GitApi.groovy:13)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
    at groovy.lang.MetaClassImpl$GetBeanMethodMetaProperty.getProperty(MetaClassImpl.java:3465)
    at org.codehaus.groovy.runtime.callsite.GetEffectivePogoPropertySite.getProperty(GetEffectivePogoPropertySite.java:84)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231)
    at com.entagen.jenkins.JenkinsJobManager.syncWithRepo(JenkinsJobManager.groovy:31)
    at com.entagen.jenkins.JenkinsJobManager$syncWithRepo.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
    at com.entagen.jenkins.Main.main(Main.groovy:28)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
    at java.lang.ProcessImpl.start(ProcessImpl.java:30)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
    ... 31 more

It happens because in windows git.cmd is used. But I guess java tries to find an executable file

Need control of BUILD_NUMBER variable for generated jobs for -SNAPSHOT vs -BUILD_NUMBER

This is a feature request more than a bug.
My build jobs use:
-DBUILD_NUMBER=${BUILD_NUMBER}
to set the artifact version.

I want my MyJob-build-master job to use the actual -BUILD_NUMBER so that it gets pushed into my nexus release repository whereas I want my other generated branch build jobs to use -SNAPSHOT so they don't go into the nexus snapshot repository.

So the generated build jobs need to use
-DBUILD_NUMBER=${BUILD_NUMBER}-SNAPSHOT

The straight up "master" -> "branch" replacement that's done can't manage this additional change.

There is no other argument one can provide to denote which nexus repo artifacts are saved into, it is always gleaned from the version string.

This requires that I have a template build job that uses -SNAPSHOT that is separate from my master job just to get this functionality. Not a huge problem, but it results in one additional job to be kept in sync by hand.

Documentation page is down

Site with documentation gets 404 code.
_$ curl -I http://entagen.github.io/jenkins-build-per-branch/_
HTTP/1.1 404 Not Found
Server: GitHub.com
Content-Type: text/html; charset=utf-8
ETag: "5519ee21-247c"
Access-Control-Allow-Origin: *
Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; img-src data:; connect-src 'self'
X-GitHub-Request-Id: 17EB2B1B:09B4:11FC3D54:56420479
Content-Length: 9340
Accept-Ranges: bytes
Date: Tue, 10 Nov 2015 14:51:38 GMT
Via: 1.1 varnish, 1.1 wcg-cluster.open.ru
Age: 74
X-Served-By: cache-ams4127-AMS
X-Cache: MISS
X-Cache-Hits: 0
X-Timer: S1447167098.384587,VS0,VE91
Vary: Accept-Encoding
X-Fastly-Request-ID: ac3b87c922fa999b352721d9c54309939282d2cd

And it is not just for me: http://downforeveryoneorjustme.com/http://entagen.github.io/jenkins-build-per-branch/

Support Multiple SCM Plugin

Hi folks,

I have used this plugin to great success previously. Today, however, I was setting up a job with 2 git checkouts using the Multiple SCM plugin. Unfortunately, this plugin is setting each of the git repositories to check out from the new branch, not just the one that matches the one I give the script with the git url argument.

Thoughts?

Jenkins CreateItem Job is not bulidable

The problem is as follows. I have created a feature branch and ran the syncWithRepo. As a result, it creates a Jenkins job for the branch.

When I view this job in the Jenkins server, it appears (from myjob/api/xml?xpath=*/buildable) that the job is not buildable. More so, the "build now" link is missing.

Restarting the service somewhat update this job as buildable. But this solution is simply not practical, as you can see.

Hence I was wondering: Does anybody knows how to fix it? I try to see the issues stated here, but failed to find any solution of it.

I highly appreciate your answer, thanks. Adil.

Issue when creating a new job from a new branch

Everything look like is working fine, however every new job created is not pointing the new branch is pointing to the master branch so I ended having a new job per new branch but being cloned the master branch all the time. What am I doing wrong? Could be something that I'm missing in the template job?

Thanks,

All jobs deleted if git error

Hi,

We hit this problem this morning:

executing command: git ls-remote --heads [email protected]:xxx/yyy.git
error executing command: git ls-remote --heads [email protected]:xxx/yyy.git
ssh_exchange_identification: Connection closed by remote host
fatal: The remote end hung up unexpectedly

getting project names from http://localhost:8080/api/json
Deleting deprecated jobs:
XXX-Tests-20110815
XXX-Tests-all_new_content
            ... etc

I guess the list of branches was empty, so it deleted all the jobs. The next run created them all again, but we'd disabled a lot of them, so they all started running at once.

I think the build script should probably fail if there is a git failure. Thoughts?

Support for Nested View without views creation

It is not possible to use the Nested plugin to get all the created jobs under that view, without creating views for all of them.

-DnestedView - ex: MyProject-feature-branches - optional -
-DnoViews - ex: true - if this flag is passed, it will not create a view for each branch

Both parameters can't work together. the last one overwrites the -DnestedView

Jobs are created for already merged branches

I am a first time user and have installed your plugin. The dry run output shows that you do a git ls-remote --heads <repo> in order to find all remote branches. Later for each of those specified by my branch name regex a job is created according to the output, 25 branches all in all, even though only 10 of them are unmerged to master, which 'I double-checked with git branch -r --no-merged origin/master.

Before I switch from dry run mode to active, I would like to know if this is a bug or if a subsequent run will remove the builds for those already merged branches again. The description does not say anythiong about it.

BTW, can I also use the plugin to create builds which are unmerged with regard to another branch than master, e.g. if I only want to see unmerged story branches with regard to our current sprint branch?

Jobs not matching branch regex are deleted

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.

Unable to resolve groovy dependency

Could not resolve all dependencies for configuration ':compile'.
> Could not find any version that matches org.codehaus.groovy:groovy:[1.5,1.7.99].
  Required by:
      :jenkins-build-per-branch:unspecified > org.codehaus.groovy.modules.http-builder:http-builder:0.5.2

Looks like Http-Builder has a dependency on a version of groovy that doesn't exist in maven central anymore.

Need a way to have jobs disabled on creation

We have several jobs (10 or so) that run on the master. We don't have enough executors to support running all of those jobs for every single branch. Also, not all jobs are that important for certain changes. We have jobs that run GUI integration tests that don't really need to be run for non GUI changes. It would be nice to have a flag for whether all jobs are disabled (even if the master job is enabled).

Server Error 500 issues with scalability?

Hi,
Using af18a93 I set up two master template jobs on Jenkins and 7 feature branches in the targeted git repo. I set up a jenkins job to run the syncWithRepo and it gets through ~1-5 them and then throws a "HTTP/1.1 500 Server Error 500" which is logged as "Caused by: java.lang.IllegalStateException: Cannot create a session after the response has been committed" in catalina.out
If I repeatedly run the sync job it will eventually create all 14 jobs and add them to their respective views but it takes ~4-5 failed attempts to work through them.

I've seen the same behavior on two separate jenkins instances:
Jenkins ver. 1.554.2.2 (Jenkins Enterprise by CloudBees 14.05) on Jetty
Jenkins ver. 1.536 on Tomcat 6.0.35
Both running on CentOS 6.3 hosts

Console Output
https://gist.github.com/sundaymtn/6cd7b04f51c5010a5fed#file-syncwithrepo_jenkinsoutput

Tomcat Output
https://gist.github.com/sundaymtn/4d80798d58b067b8b56f#file-catalina-out

Get internal server error (500) when attempting to get views

getting views - nestedWithinView:THOSE-Branches at path: view/THOSE-Branches/api/json
Exception in thread "main" java.lang.Exception: Unexpected failure with path https://xxx.yyy.com/jenkins/view/THOSE-Branches/api/json, HTTP Status Code: 500, full map: [path:view/THOSE-Branches/api/json, query:[tree:views[name,jobs[name]]]]

I'm new to Groovy, JSON, Jenkins Remote API, but if I do https://xxx.yyy.com/jenkins/view/THOSE-Branches/api/json?tree=views[name] I do get a valid response with the names of all the views, but each view element does not have a jobs field.

If I do https://xxx.yyy.com/jenkins/view/THOSE-Branches/api/json, I see the views, but the root jobs field is an empty list (which I think makes sense since I'm using the nested view option). Even if I create a view manually within the nested view that I can view from a browser, I still don't see jobs listed in any of the URLs I have tried.

I should also add a get another warning, when I try to look at the created views with a root exception of:
Caused by: java.lang.NullPointerException: Cannot invoke method isEmpty() on null object
at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:32)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:54)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
at hudson.model.View.main.run(main.groovy:6)
at org.kohsuke.stapler.jelly.groovy.GroovierJellyScript.run(GroovierJellyScript.java:69)
at org.kohsuke.stapler.jelly.groovy.GroovierJellyScript.run(GroovierJellyScript.java:62)
at org.kohsuke.stapler.jelly.IncludeTag.doTag(IncludeTag.java:146)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
... 102 more

If I enter the same offending URL in a browser I see there is a class cast exception in the bowels of Jenkins. I assume this might be the root cause of the issue, but don't know the way around it. Perhaps the Jenkins Remote API will ignore this issue if you don't specially ask to look at the jobs within a view.
java.io.IOException: Failed to write jobs
at org.kohsuke.stapler.export.Property.writeTo(Property.java:120)
at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:187)
at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:182)
at org.kohsuke.stapler.export.Property.writeValue(Property.java:232)
at org.kohsuke.stapler.export.Property.writeValue(Property.java:182)
at org.kohsuke.stapler.export.Property.writeValue(Property.java:137)
at org.kohsuke.stapler.export.Property.writeTo(Property.java:114)
at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:187)
at org.kohsuke.stapler.export.Model.writeTo(Model.java:154)
at org.kohsuke.stapler.ResponseImpl.serveExposedBean(ResponseImpl.java:267)
at hudson.model.Api.doJson(Api.java:193)
at sun.reflect.GeneratedMethodAccessor1073.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:297)
at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:160)
at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:95)
at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:111)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:685)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:799)
at org.kohsuke.stapler.MetaClass$4.doDispatch(MetaClass.java:201)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:685)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:799)
at org.kohsuke.stapler.MetaClass$6.doDispatch(MetaClass.java:239)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:685)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:799)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:587)
at org.kohsuke.stapler.Stapler.service(Stapler.java:218)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:45)
at winstone.ServletConfiguration.execute(ServletConfiguration.java:248)
at winstone.RequestDispatcher.forward(RequestDispatcher.java:333)
at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:376)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:96)
at hudson.plugins.scm_sync_configuration.extensions.ScmSyncConfigurationFilter$1.call(ScmSyncConfigurationFilter.java:46)
at hudson.plugins.scm_sync_configuration.ScmSyncConfigurationDataProvider.provideRequestDuring(ScmSyncConfigurationDataProvider.java:103)
at hudson.plugins.scm_sync_configuration.extensions.ScmSyncConfigurationFilter.doFilter(ScmSyncConfigurationFilter.java:42)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:99)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:208)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:181)
at net.bull.javamelody.PluginMonitoringFilter.doFilter(PluginMonitoringFilter.java:86)
at org.jvnet.hudson.plugins.monitoring.HudsonMonitoringFilter.doFilter(HudsonMonitoringFilter.java:84)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:99)
at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:88)
at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:48)
at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:117)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(BasicProcessingFilter.java:174)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at jenkins.security.ApiTokenFilter.doFilter(ApiTokenFilter.java:64)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76)
at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:164)
at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:46)
at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:81)
at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
at winstone.RequestDispatcher.forward(RequestDispatcher.java:331)
at winstone.RequestHandlerThread.processRequest(RequestHandlerThread.java:227)
at winstone.RequestHandlerThread.run(RequestHandlerThread.java:150)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.kohsuke.stapler.export.MethodProperty.getValue(MethodProperty.java:66)
at org.kohsuke.stapler.export.Property.writeTo(Property.java:114)
... 88 more
Caused by: java.lang.ClassCastException: hudson.matrix.MatrixConfiguration cannot be cast to hudson.model.TopLevelItem
at hudson.model.ListView.expand(ListView.java:189)
at hudson.model.ListView.expand(ListView.java:192)
at hudson.model.ListView.getItems(ListView.java:178)
at hudson.model.ListView.getItems(ListView.java:60)
... 94 more

Jobs created from template don't copy over Build Triggers

I have my template set to build after the syncWithRepo job. After my first run and all the jobs for all the branches were created, only the master (template) built. I know there is a flag for it to start right away, but I them all to run after the main job runs so they can rebuild if the repo changes. Build Triggers are empty on the newly created jobs, so I have to run them manually every time which does not make for good automation. :)

Thanks!

404 on view configSubmit if there are more than one missing views

Hi,

not sure what's happening here, but I constantly get this exception:

getting project names from http://localhost:8080/api/json
getting views - nestedWithinView:ourrepo-branches at path: view/ourrepo-branches/api/json
Missing views: [ourrepo-force-https, ourrepo-jenkins, ourrepo-master, ourrepo-new-data-model, ourrepo-save-reports, ourrepo-scrape-kdp-stats, ourrepo-sentry]
creating view - viewName:ourrepo-force-https, nestedView:ourrepo-branches
Trying to find crumb: http://localhost:8080/crumbIssuer/api/json
Couldn't find crumbIssuer for jenkins. Just moving on it may not be needed.
configuring view ourrepo-force-https
creating view - viewName:ourrepo-jenkins, nestedView:ourrepo-branches
configuring view ourrepo-jenkins
creating view - viewName:ourrepo-master, nestedView:ourrepo-branches
configuring view ourrepo-master
Exception in thread "main" java.lang.Exception: Unexpected failure on http://localhost:8080/view/ourrepo-branches/view/ourrepo-master/configSubmit: HTTP/1.1 404 Not Found 404

This only happens when the job needs to create more than one view.

When I run the job several times again until all the views are created it runs like it should - maybe our server is just not fast enough to create the view so configuring fails? No idea... Jenkins is pretty fast, so I don't think this is the problem...

Jenkins version: 1.492

Unable to find any jobs matching template regex: ^(myProject-[^-]*)-(feature)$

Hi I'm struggling to get this to work, I have a template job called myProj-build-feature and my switches are:-
-DjenkinsUrl=http://localhost:8080 -DgitUrl=[email protected]:{company}/myProject.git -DtemplateJobPrefix=myProject -DtemplateBranchName=feature -DdryRun=true

but yet I always get the following message
You need at least one job to match the templateJobPrefix and templateBranchName suffix arguments. Expression: (templateJobs?.size() > 0)

And all my fixes are in the 'feature' branch in gitHub

any clues?

Incorrect branch names in newly spawned jobs

Hi,
As part of gradle switches I entered the following...
-DjenkinsUrl=http://forge:8080 -DgitUrl=git@scm:product/platform -DtemplateJobPrefix=MINT_Platform_3.7 -DtemplateBranchName=develop -DbranchNameRegex=.*/v37/feature/MINT-.+ -DjenkinsUser=xxxx -DjenkinsPassword=xxxx -DstartOnCreate=true -DnestedView=Wolverine

The branches matching my regex are correctly identified:
10:05:53 executing command: git ls-remote --heads git@scm:product/platform
10:05:54 944bdbc4c66082be384ebc9b697c9926e39b5cab refs/heads/develop
10:05:54 0de938a7a5838d411ffef4d5bbc009c1c30344ba refs/heads/feature/MINT-1328-sam-lifecycle
10:05:54 c4ab58609decebf671dce70b4467cde7932c19b8 refs/heads/feature/MINT-1330
10:05:54 b196866cb62053d7d0fa93912e1a0ba83855218c refs/heads/feature/MINT-1331
10:05:54 fd599c0905d3ddd107d75eaedbdc5b1e7560bcf5 refs/heads/feature/MINT-1353
10:05:54 7d4ab98cdc85f1f041e1a70b7cb909c5d128035a refs/heads/feature/MINT-1368
10:05:54 a8fbcce869520885e6c1b30f169ec55df74a0679 refs/heads/feature/MINT-1371
10:05:54 7d3014bb13d9cd4a8bfa54fa6d4aa2b4b2764585 refs/heads/feature/MINT-1378
10:05:54 cbe8b0f5522768b461294323d47c9bd1bb7b2064 refs/heads/feature/MINT-1390
10:05:54 588fcaf5b5a6250cd385307f68b7c86f41bbfd4d refs/heads/feature/MINT-1441
10:05:54 20bd990fd9d73eedff844720f9ac6e8e2eeefc02 refs/heads/feature/MINT-1449
10:05:54 650e91c29d654b6af2c5916a7ae900497143a1cf refs/heads/feature/MINT-1453
10:05:54 b6435fb2f799f4d5cdbe63984a7ceb8e8afe9fba refs/heads/feature/MINT-357
10:05:54 73a7f87688f55ca7f8dd8d036ece169f2148a0d7 refs/heads/master
10:05:54 a6b089d8cce683aed85becb5dcff02233a9aa98d refs/heads/support/v3.5
10:05:54 3e59d628d6d4f3f867af58a04333d328af7b6ead refs/heads/support/v3.7
10:05:54 caee7b0054754cd9d6db0aba6929c826840677b4 refs/heads/support/v37/develop
10:05:54 * d5583f156a64528b57177c7f0b116b3803d2d400 refs/heads/support/v37/feature/MINT-1329
10:05:54 * c169316ba713071968f315dfb6d4e32de241cf17 refs/heads/support/v37/feature/MINT-1446
10:05:54 * 8af32416ac0ddf63a03ab2476d74d8964358bac2 refs/heads/support/v37/feature/MINT-1452

See the ones marked in asterix....
However the newly spawned jobs show the following as their branch specifiers
support/v37/support/v37/feature/MINT-1329
support/v37/support/v37/feature/MINT-1446
support/v37/support/v37/feature/MINT-1452

Notice that support/v37 occurs twice as part of the branch specifier on the newly created jobs. I think this is a bug.
Thanks!

Does not work with version of 2.x of gradle

I finally went back to 1.11 and it started working again.

For 2.x versions of gradle, the error is:

0 %> gradle --debug -DOPTIONS=-DdryRun=true -DjenkinsUrl=http://build:8080 -DdryRun=true -DgitUrl=git@XXXX:XXXX -DtemplateJobPrefix=CAS -DtemplateBranchName=develop -DnestedView=CAS-generated -DbranchNameRegex=feature/.+|hotfix/.+|release/.+ -DjenkinsUser=XXXX -DjenkinsPassword=XXXX syncWithRepo
zsh: no such file or directory: hotfix/.+
zsh: no such file or directory: release/.+
12:11:03.843 [ERROR] [org.gradle.BuildExceptionReporter]
12:11:03.847 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
12:11:03.849 [ERROR] [org.gradle.BuildExceptionReporter]
12:11:03.850 [ERROR] [org.gradle.BuildExceptionReporter] * Where:
12:11:03.851 [ERROR] [org.gradle.BuildExceptionReporter] Build file '/u0/jenkins/jobs/CAS-generate-git-branch-builds/workspace/build.gradle' line: 9
12:11:03.853 [ERROR] [org.gradle.BuildExceptionReporter]
12:11:03.854 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
12:11:03.855 [ERROR] [org.gradle.BuildExceptionReporter] A problem occurred evaluating root project 'workspace'.
12:11:03.857 [ERROR] [org.gradle.BuildExceptionReporter] > Could not find method groovy() for arguments [org.codehaus.groovy:groovy-all:1.8.8] on root project 'workspace'.
12:11:03.858 [ERROR] [org.gradle.BuildExceptionReporter]
12:11:03.860 [ERROR] [org.gradle.BuildExceptionReporter] * Try:
12:11:03.861 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.

Build failing - testFindTemplateJobs_noMatchingJobsThrowsException

When I run ./gradlew locally on master branch for this, I get one job failing:

testFindTemplateJobs_noMatchingJobsThrowsException

Assertion failed: 

assert result == "Unable to find any jobs matching template regex: ^(myproj-.*)-(master)\$\nYou need at least one job to match the templateJobPrefix and templateBranchName suffix arguments. Expression: (templateJobs?.size() > 0)"
       |      |
       |      false
       Unable to find any jobs matching template regex: ^(myproj-[^-]*)-(master)$
       You need at least one job to match the templateJobPrefix and templateBranchName suffix arguments. Expression: (templateJobs?.size() > 0)

    at org.codehaus.groovy.runtime.InvokerHelper.assertFailed(InvokerHelper.java:386)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.assertFailed(ScriptBytecodeAdapter.java:658)
    at com.entagen.jenkins.JenkinsJobManagerTests.testFindTemplateJobs_noMatchingJobsThrowsException(JenkinsJobManagerTests.groovy:32)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at junit.framework.TestCase.runTest(TestCase.java:168)
    at junit.framework.TestCase.runBare(TestCase.java:134)
    at junit.framework.TestResult$1.protect(TestResult.java:110)
    at junit.framework.TestResult.runProtected(TestResult.java:128)
    at junit.framework.TestResult.run(TestResult.java:113)
    at junit.framework.TestCase.run(TestCase.java:124)
    at junit.framework.TestSuite.runTest(TestSuite.java:243)
    at junit.framework.TestSuite.run(TestSuite.java:238)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:55)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:42)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:75)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:49)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
    at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
    at $Proxy2.processTestClass(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:101)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.messaging.remote.internal.TypeCastDispatch.dispatch(TypeCastDispatch.java:30)
    at org.gradle.messaging.remote.internal.WorkerProtocol.handleIncoming(WorkerProtocol.java:53)
    at org.gradle.messaging.remote.internal.WorkerProtocol.handleIncoming(WorkerProtocol.java:31)
    at org.gradle.messaging.remote.internal.ProtocolStack$ProtocolStage.handleIncoming(ProtocolStack.java:167)
    at org.gradle.messaging.remote.internal.ProtocolStack$BottomStage.handleIncoming(ProtocolStack.java:277)
    at org.gradle.messaging.remote.internal.ProtocolStack$BottomConnection$1.run(ProtocolStack.java:299)
    at org.gradle.messaging.remote.internal.ProtocolStack$ExecuteRunnable.dispatch(ProtocolStack.java:120)
    at org.gradle.messaging.remote.internal.ProtocolStack$ExecuteRunnable.dispatch(ProtocolStack.java:116)
    at org.gradle.messaging.dispatch.AsyncDispatch.dispatchMessages(AsyncDispatch.java:132)
    at org.gradle.messaging.dispatch.AsyncDispatch.access$000(AsyncDispatch.java:33)
    at org.gradle.messaging.dispatch.AsyncDispatch$1.run(AsyncDispatch.java:72)
    at org.gradle.messaging.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:680)

Couldn't find crumbIssuer for Jenkins

Trying to find crumb: https://ci.example.com/jenkins/crumbIssuer/api/json
Couldn't find crumbIssuer for jenkins. Just moving on it may not be needed.
Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1086)
	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1044)
	at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:515)
	at groovyx.net.http.HTTPBuilder.post(HTTPBuilder.java:352)
	at groovyx.net.http.HTTPBuilder$post.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
	at com.entagen.jenkins.JenkinsApi.post(JenkinsApi.groovy:220)
	at com.entagen.jenkins.JenkinsApi.post(JenkinsApi.groovy)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrap.invoke(PogoMetaMethodSite.java:190)
	at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
	at com.entagen.jenkins.JenkinsApi.deleteJob(JenkinsApi.groovy:102)
	at com.entagen.jenkins.JenkinsApi$deleteJob$0.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
	at com.entagen.jenkins.JenkinsJobManager$_deleteDeprecatedJobs_closure2.doCall(JenkinsJobManager.groovy:77)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1021)
	at groovy.lang.Closure.call(Closure.java:426)
	at groovy.lang.Closure.call(Closure.java:442)
	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2030)
	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2015)
	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2056)
	at org.codehaus.groovy.runtime.dgm$162.invoke(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
	at com.entagen.jenkins.JenkinsJobManager.deleteDeprecatedJobs(JenkinsJobManager.groovy:76)
	at com.entagen.jenkins.JenkinsJobManager$deleteDeprecatedJobs$5.callCurrent(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
	at com.entagen.jenkins.JenkinsJobManager.syncJobs(JenkinsJobManager.groovy:55)
	at com.entagen.jenkins.JenkinsJobManager$syncJobs$1.callCurrent(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:182)
	at com.entagen.jenkins.JenkinsJobManager.syncWithRepo(JenkinsJobManager.groovy:40)
	at com.entagen.jenkins.JenkinsJobManager$syncWithRepo.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
	at com.entagen.jenkins.Main.main(Main.groovy:30)
Caused by: java.lang.Exception: Unexpected failure on https://ci.example.com/jenkins/job/NTDPDrupal-build-feature_1906/doDelete: HTTP/1.1 403 Forbidden 403
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
	at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:77)
	at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:84)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:247)
	at com.entagen.jenkins.JenkinsApi$_post_closure6.doCall(JenkinsApi.groovy:217)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1021)
	at groovy.lang.Closure.call(Closure.java:426)
	at groovyx.net.http.HTTPBuilder$1.handleResponse(HTTPBuilder.java:503)
	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1070)
	... 59 more
:syncWithRepo FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':syncWithRepo'.
> Process 'command '/usr/java/jdk1.8.0_92/bin/java'' finished with non-zero exit value 1

Related: #31, #101

Unable to create jobs when branch contains % in the name

I'm using Jenkins 1.532.1.

At first I thought it was a problem in general, but noticed the first branch had a % in it. I created a new branch that would be tried first and it seemed to work.

Console output for the sync job:

getting project names from https://xxx.yyy.com/jenkins/api/json
Creating missing job: xxxyyy-Docs-some%branch from xxxyyyGit-Docs-master
Trying to find crumb: https://xxx.yyy.com/jenkins/crumbIssuer/api/json
Couldn't find crumbIssuer for jenkins. Just moving on it may not be needed.

Exception in thread "main" java.lang.Exception: Unexpected failure on https://xxx.yyy.com/jenkins/createItem: HTTP/1.1 400 Bad Request 400
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:71)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:81)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:54)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
at com.entagen.jenkins.JenkinsApi$_post_closure6.doCall(JenkinsApi.groovy:213)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:877)
at groovy.lang.Closure.call(Closure.java:412)
at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:508)
at groovyx.net.http.HTTPBuilder.post(HTTPBuilder.java:359)
at groovyx.net.http.HTTPBuilder$post.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at com.entagen.jenkins.JenkinsApi.post(JenkinsApi.groovy:216)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:267)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:52)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:153)
at com.entagen.jenkins.JenkinsApi.cloneJobForBranch(JenkinsApi.groovy:59)
at com.entagen.jenkins.JenkinsApi$cloneJobForBranch.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at com.entagen.jenkins.JenkinsJobManager.createMissingJobs(JenkinsJobManager.groovy:64)
at com.entagen.jenkins.JenkinsJobManager$createMissingJobs.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
at com.entagen.jenkins.JenkinsJobManager.syncJobs(JenkinsJobManager.groovy:52)
at com.entagen.jenkins.JenkinsJobManager$syncJobs.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
at com.entagen.jenkins.JenkinsJobManager.syncWithRepo(JenkinsJobManager.groovy:39)
at com.entagen.jenkins.JenkinsJobManager$syncWithRepo.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
at com.entagen.jenkins.Main.main(Main.groovy:29)
:syncWithRepo FAILED

Caused by: java.lang.Exception: Unexpected failure on /job/build/doDelete: HTTP/1.1 403 Forbidden 403

Trying to find crumb: https://ci.example.com/crumbIssuer/api/json
Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1086)
	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1044)
	at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:515)
	at groovyx.net.http.HTTPBuilder.post(HTTPBuilder.java:352)
	at groovyx.net.http.HTTPBuilder$post.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
	at com.entagen.jenkins.JenkinsApi.post(JenkinsApi.groovy:220)
	at com.entagen.jenkins.JenkinsApi.post(JenkinsApi.groovy)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrap.invoke(PogoMetaMethodSite.java:190)
	at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
	at com.entagen.jenkins.JenkinsApi.deleteJob(JenkinsApi.groovy:102)
	at com.entagen.jenkins.JenkinsApi$deleteJob$0.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
	at com.entagen.jenkins.JenkinsJobManager$_deleteDeprecatedJobs_closure2.doCall(JenkinsJobManager.groovy:77)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1021)
	at groovy.lang.Closure.call(Closure.java:426)
	at groovy.lang.Closure.call(Closure.java:442)
	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2030)
	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2015)
	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2056)
	at org.codehaus.groovy.runtime.dgm$162.invoke(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
	at com.entagen.jenkins.JenkinsJobManager.deleteDeprecatedJobs(JenkinsJobManager.groovy:76)
	at com.entagen.jenkins.JenkinsJobManager$deleteDeprecatedJobs$5.callCurrent(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
	at com.entagen.jenkins.JenkinsJobManager.syncJobs(JenkinsJobManager.groovy:55)
	at com.entagen.jenkins.JenkinsJobManager$syncJobs$1.callCurrent(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:182)
	at com.entagen.jenkins.JenkinsJobManager.syncWithRepo(JenkinsJobManager.groovy:40)
	at com.entagen.jenkins.JenkinsJobManager$syncWithRepo.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
	at com.entagen.jenkins.Main.main(Main.groovy:30)
Caused by: java.lang.Exception: Unexpected failure on https://ci.example.com/job/NTDPDrupal-build-feature_1906/doDelete: HTTP/1.1 403 Forbidden 403
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
	at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:77)
	at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:84)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:247)
	at com.entagen.jenkins.JenkinsApi$_post_closure6.doCall(JenkinsApi.groovy:217)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1021)
	at groovy.lang.Closure.call(Closure.java:426)
	at groovyx.net.http.HTTPBuilder$1.handleResponse(HTTPBuilder.java:503)
	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1070)
	... 59 more
:syncWithRepo FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':syncWithRepo'.
> Process 'command '/usr/java/jdk1.8.0_92/bin/java'' finished with non-zero exit value 1

Going to /crumbIssuer/api/json shows the correct response, e.g.

{"_class":"hudson.security.csrf.DefaultCrumbIssuer","crumb":"xxx","crumbRequestField":"Jenkins-Crumb"}
but maybe it's not parsed correctly.

Related: #98, #20

The code fails in JenkinsApi.groovy on deleteJob():

    http.post(path: path, body: postBody, query: params,
            requestContentType: contentType) { resp ->
        assert resp.statusLine.statusCode < 400
        status = resp.statusLine.statusCode
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.