Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

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

0 votes


Accepted answer

Permanent link
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

0 votes

Comments

 Ohh. Missed that. Checking...

 Worked. Thanks.


2 other answers

Permanent link
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

0 votes

Comments

Ralph, Considered already :-)

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

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.

Right. I used the code as you specified. 


Still doesn't work :-(

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
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)

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,930

Question asked: Jul 25 '16, 1:21 a.m.

Question was seen: 2,343 times

Last updated: Jul 27 '16, 1:05 a.m.

Confirmation Cancel Confirm