Thanks Robert,

I'm going to go with your solution.  Executing this using the groovy 
postbuild action works:

manager.hudson.getItemByFullName("Target").getScm().getBranches().get(0).setName("newBranch");

Phil


On Friday, June 12, 2015 at 7:05:22 AM UTC-7, Robert Sandell wrote:
>
> A plugin or groovy script could quite easily change the git branch of a 
> job, something like:
>
>
> Jenkins.getInstance().getItemByFullName("Target").getScm().setBranch("newBranch");
>
> But you could also try using the envinject plugin in Target to fetch the 
> contents of a stored artifact in the lastSuccessfullBuild of Modifier?
>
> /B
>
> On Fri, Jun 12, 2015 at 3:58 PM, Phil C <phil...@gmail.com <javascript:>> 
> wrote:
>
>> Hi Ben,
>>
>> Yes, I looked at the Job DSL plugin a bit.  It looks like it currently 
>> only provides the ability to create new jobs.  I couldn't find a way to 
>> modify an existing job.  I only read through the documentation, and haven't 
>> actually tried messing around with it yet though.  Maybe I'm missing 
>> something?
>>
>> In any case, if I do end up implementing job modification functionality, 
>> I will look into adding this functionality to the Job DSL plugin, rather 
>> than creating an entirely new plugin.
>>
>> Phil
>>
>>
>> On Friday, June 12, 2015 at 5:50:05 AM UTC-7, Ben Patterson wrote:
>>>
>>> Phil, have you looked at the Job DSL plugin? It sounds to me like that 
>>> might be useful for you here.
>>>
>>> https://wiki.jenkins-ci.org/display/JENKINS/Job+DSL+Plugin, and 
>>> https://github.com/jenkinsci/job-dsl-plugin/wiki
>>>
>>> On Friday, June 12, 2015 at 1:05:48 AM UTC-4, Phil C wrote:
>>>>
>>>> Hi,
>>>>
>>>> I'd like to be able to modify another job's configuration from a 
>>>> build.  Specifically, I would like to modify the git branch that is used 
>>>> by 
>>>> another job.
>>>>
>>>> I'm looking for any ideas on how this would be possible currently.  And 
>>>> I am considering writing a plugin (or contributing to an appropriate 
>>>> plugin) for this.
>>>>
>>>> The only way I can think of how this is possible right now (without a 
>>>> plugin) is to have a script (groovy?) access the REST interface to 
>>>> retrieve 
>>>> and set the config.xml.  e.g.:
>>>>
>>>>    1. Get a project's config.xml by issuing an HTTP GET 
>>>>    /job/jobname/config.xml.
>>>>    2. Modify the config.xml in the script
>>>>    3. HTTP POST the modified config.xml back to the same address
>>>>
>>>> The downside of this approach is that it requires credentials to make 
>>>> the POST, and it requires complex logic in the script for step 2.
>>>>
>>>> I'm thinking a plugin could accomplish the same thing easily without 
>>>> going through HTTP, but instead using internal apis.  The plugin would 
>>>> take 
>>>> a job name as input, and a set of modifiers to be performed on that job's 
>>>> config.xml.  Modifiers for common things like git branch can be provided 
>>>> out of the box.  Also, a generic XSLT modifier can be provided to allow 
>>>> modification of ANY part of the config.xml (user would provide the XSLT 
>>>> transformation).  Extension points could be provided to allow other 
>>>> modifiers to be developed.
>>>>
>>>> Anyway, let me know your thoughts?  Any other ways this can be done?  
>>>> Any existing plugins where this logic would be a good fit? 
>>>>
>>>> Thanks,
>>>>
>>>> Phil
>>>>
>>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Jenkins Developers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to jenkinsci-de...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-dev/5794ed87-5005-4ee3-ad16-952dc592d1fa%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jenkinsci-dev/5794ed87-5005-4ee3-ad16-952dc592d1fa%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Robert Sandell
> *Software Engineer*
> *CloudBees Inc.*
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/8809105d-75bc-44da-997d-84056ff88bf5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to