It's all about the answers!

Ask a question

Define the Hudson/Jenkins Job to run in build definition programtically


Liora Milbaum (513282117) | asked Jul 25 '16, 1:21 a.m.
CLM 6.0.2

Here is the code to achieve that, BUT, it is not working.  Would appreciate your assistance. 

IBuildDefinition definitionWC = (IBuildDefinition)definition.getWorkingCopy();

definition.setConfigurationProperty(HudsonConfigurationElement.ELEMENT_IDHudsonConfigurationElement.PROPERTY_HUDSON_JOB, "<Jenkins Job Name>"); 

definitionWC = buildClient.save(definitionWC, new NullProgressMonitor());


Liora

Accepted answer


permanent link
Sridevi Sangaiah (59179) | answered Jul 27 '16, 12:12 a.m.
JAZZ DEVELOPER
Hope you are updating the working copy of the build definition. Looking at the code included in the initial post,

IBuildDefinition definitionWC = (IBuildDefinition)definition.getWorkingCopy();

definition.setConfigurationProperty(HudsonConfigurationElement.ELEMENT_IDHudsonConfigurationElement.PROPERTY_HUDSON_JOB, "<jenkins Job="" Name="">"); 

definitionWC = buildClient.save(definitionWC, new NullProgressMonitor());

It should be definitionWC.setConfigurationProperty() and not definition.setConfigurationProperty()

Thanks,

Sridevi



Liora Milbaum selected this answer as the correct answer

Comments
Liora Milbaum commented Jul 27 '16, 12:16 a.m.

 Ohh. Missed that. Checking...


Liora Milbaum commented Jul 27 '16, 1:05 a.m.

 Worked. Thanks.

2 other answers



permanent link
Ralph Schoon (63.1k33645) | answered Jul 25 '16, 2:30 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Consider https://www.google.com/search?q=buildClient.save+Jenkins+site:jazz.net the first result.
.....BUT, it is not working.... is not a whole lot of information, really

Comments
Liora Milbaum commented Jul 25 '16, 2:32 a.m.

Ralph, Considered already :-)

I have reason to believe the first argument of setConfigurationProperty function call is not correct. 


Sridevi Sangaiah commented Jul 26 '16, 7:17 a.m. | edited Jul 26 '16, 7:17 a.m.
JAZZ DEVELOPER

Hi Liora,

Can you try this definition.setConfigurationProperty(HudsonConfigurationElement.ELEMENT_IDHudsonConfigurationElement.PROPERTY_HUDSON_JOB, "<job name>");

Replace the <job name> with the name of the jenkins job.


Liora Milbaum commented Jul 26 '16, 7:40 a.m.

Right. I used the code as you specified. 


Still doesn't work :-(


Ralph Schoon commented Jul 26 '16, 7:53 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

What does "does not work" mean? What errors, what issues in the debugger? See https://jazz.net/forum/questions/203755/how-should-i-ask-a-question-in-the-forum-if-i-want-to-receive-useful-answers for information you should provide.


permanent link
Liora Milbaum (513282117) | answered Jul 26 '16, 4:21 p.m.
The stuck trace:

Exception in thread "main" com.ibm.team.repository.common.internal.ImmutablePropertyException

at com.ibm.team.repository.common.internal.util.ItemUtil$ProtectAdapter.notifyChanged(ItemUtil.java:2143)

at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:380)

at com.ibm.team.build.internal.common.model.impl.ConfigurationPropertyImpl.setValue(ConfigurationPropertyImpl.java:204)

at com.ibm.team.build.internal.common.model.impl.BuildDefinitionImpl.setConfigurationProperty(BuildDefinitionImpl.java:1345)

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 com.ibm.team.repository.common.internal.util.ItemStore$ItemInvocationHandler.invoke(ItemStore.java:597)

at com.sun.proxy.$Proxy20.setConfigurationProperty(Unknown Source)

at BuildDefinitionUtils.CreateBuildDefinition(BuildDefinitionUtils.java:41)

at RTCBuild.main(RTCBuild.java:30)

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.