It's all about the answers!

Ask a question

Ant task to create Work Items/Deployment Requests/etc?


Chris Graham (367914) | asked Oct 31 '11, 2:45 a.m.
Hi All.

Do we have them?

Is there a means to be able to autoamtically create Work Items?

I'd like to be able to create a Deployment Request etc, when I complete my builds.

-Chris

5 answers



permanent link
Chris Graham (367914) | answered Nov 14 '11, 10:51 p.m.
Hi Chris,

I am not aware of such a task. You can create work items using OSLC or using Java and the Plain Java Client Library. How to create work items is outlined here: https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation

Hello.

Are there any plans to do so?

I am surprised that they do not exist, as I'd have found them somewhat fundamental.

-Chris

Comments
Arne Bister commented Feb 12 '14, 7:48 a.m.
JAZZ DEVELOPER

Chris,

I am with you regarding the wish to have an easy way to create / modify work items from within an ANT build. There are two new additions which partly or completey get the job done.

1. Eclipse Lyo Perl module --> allows you to modify work items. Combined with ANT < exec > task, this will give you 1/2 the solution.

2. Add a custom task to ANT using the plain java api as described by Robin Yehle, to create / modify / link work items. It is not that hard and the complex part you only have to do once. When it is there you have the ANT task you dreamed of.

- Arne


sam detweiler commented Feb 12 '14, 8:01 a.m. | edited Feb 12 '14, 8:02 a.m.

hm.. this sounds like fun!.. never created an ANT task

what are the redistribution rules for plain java libs?


permanent link
Ralph Schoon (63.4k33646) | answered Oct 31 '11, 4:35 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi Chris,

I am not aware of such a task. You can create work items using OSLC or using Java and the Plain Java Client Library. How to create work items is outlined here: https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation

permanent link
Ralph Schoon (63.4k33646) | answered Nov 15 '11, 2:05 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi Chris,

Since not all builds are meant to be deployed, except if you have an automated test bench, I would suggest to open the build result of the public build, review it and then use the link &quot;Create a work item for this build&quot; to create the work item if it is supposed to be deployed. The work item will be automatically linked to the build result providing all necessary information for the release engineer. Why creating work items for builds that does not need deployment?

permanent link
Chris Graham (367914) | answered Nov 15 '11, 9:58 p.m.
Ah. I can see coming from an Ant centric mode of thinking, how you'd think this.

But in this case, it's a bad assumption.

We're using Maven, a somewhat more advanced/elegant tool.

It has the concepts of build _phases_. Compile, Package, Install (to a local maven repository) and deploy (to a remote maven repository - not an actual deployment of code into an environment).

We only use the deploy phase when performing a formal release (against a tag).

So, I'd tie the maven ant-run plugin (to execute said non-existant ant tasks) to the deploy phase, so that it only runs when performing a formal release. We only do this when we want to actually deploy the code into a non-dev environment, potentially all the way up to production.

So, in this way, I'd be removing manual processes, automating them, only crating the work items, when necessary.

Additionally, and this is the bit that really surprises me, is that I'd like to open a Defect Work Item against the developer broke the build. That would be something that could be done for each build etc. I hope you get the idea.

-Chris
Hi Chris,

Since not all builds are meant to be deployed, except if you have an automated test bench, I would suggest to open the build result of the public build, review it and then use the link &quot;Create a work item for this build&quot; to create the work item if it is supposed to be deployed. The work item will be automatically linked to the build result providing all necessary information for the release engineer. Why creating work items for builds that does not need deployment?

permanent link
Ralph Schoon (63.4k33646) | answered Nov 16 '11, 3:50 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi,

as already mentioned, as far as I know that ant task does not exist as far as http://publib.boulder.ibm.com/infocenter/clmhelp/v3r0m1/topic/com.ibm.team.build.doc/topics/r_ant-tasks.html goes. The WorkItemPublisher publishes the work items related to the changes to the build result.

You can easily use the Plain Java Client Library also called Plain Java API in some places to create a work item as mentioned already in the first answer. See here: https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation

The Plain Java Client Library can be downloaded from the all download pages e.g. https://jazz.net/downloads/rational-team-concert/releases/3.0.1.1/RTC-Client-plainJavaLib-3.0.1.1.zip

New is the API documentation: https://jazz.net/downloads/rational-team-concert/releases/3.0.1.1/RTC-Client-plainJavaLib-API-javadoc-3.0.1.1.zip

This is the code you want to use. It is only very basic but can be extended easily to add more attributes. The Extending Team concert forum is where this is discussed. There is also example code for how to set other work item attributes. You could also create a work item here https://jazz.net/jazz/web/projects/Rational%20Team%20Concert#action=com.ibm.team.workitem.viewWelcome in case you think this is essential. I agree it would be a nice ides so I looked for a work item, but did find only this https://jazz.net/jazz/web/projects/Rational%20Team%20Concert#action=com.ibm.team.workitem.viewWorkItem&amp;id=34443 . I added your case.


public class CreateWorkItem &#123;

private static class LoginHandler implements ILoginHandler, ILoginInfo &#123;

private String fUserId;
private String fPassword;

private LoginHandler&#40;String userId, String password&#41; &#123;
fUserId= userId;
fPassword= password;
&#125;

public String getUserId&#40;&#41; &#123;
return fUserId;
&#125;

public String getPassword&#40;&#41; &#123;
return fPassword;
&#125;

public ILoginInfo challenge&#40;ITeamRepository repository&#41; &#123;
return this;
&#125;
&#125;

private static class WorkItemInitialization extends WorkItemOperation &#123;

private String fSummary;
private ICategoryHandle fCategory;

public WorkItemInitialization&#40;String summary, ICategoryHandle category&#41; &#123;
super&#40;&quot;Initializing Work Item&quot;&#41;;
fSummary= summary;
fCategory= category;
&#125;

@Override
protected void execute&#40;WorkItemWorkingCopy workingCopy, IProgressMonitor monitor&#41; throws TeamRepositoryException &#123;
IWorkItem workItem= workingCopy.getWorkItem&#40;&#41;;
workItem.setHTMLSummary&#40;XMLString.createFromPlainText&#40;fSummary&#41;&#41;;
workItem.setCategory&#40;fCategory&#41;;
&#125;
&#125;

public static void main&#40;String&#91;&#93; args&#41; &#123;

boolean result;
TeamPlatform.startup&#40;&#41;;
try &#123;
result= run&#40;args&#41;;
&#125; catch &#40;TeamRepositoryException x&#41; &#123;
x.printStackTrace&#40;&#41;;
result= false;
&#125; finally &#123;
TeamPlatform.shutdown&#40;&#41;;
&#125;

if &#40;!result&#41;
System.exit&#40;1&#41;;

&#125;

private static boolean run&#40;String&#91;&#93; args&#41; throws TeamRepositoryException &#123;

if &#40;args.length != 7&#41; &#123;
System.out.println&#40;&quot;Usage&#58; CreateWorkItem &lt;repositoryURI&gt; &lt;userId&gt; &lt;password&gt; &lt;projectArea&gt; &lt;workItemType&gt; &lt;summary&gt; &lt;category&gt;&quot;&#41;;
return false;
&#125;

String repositoryURI= args&#91;0&#93;;
String userId= args&#91;1&#93;;
String password= args&#91;2&#93;;
String projectAreaName= args&#91;3&#93;;
String typeIdentifier= args&#91;4&#93;;
String summary= args&#91;5&#93;;
String categoryName= args&#91;6&#93;;

ITeamRepository teamRepository= TeamPlatform.getTeamRepositoryService&#40;&#41;.getTeamRepository&#40;repositoryURI&#41;;
teamRepository.registerLoginHandler&#40;new LoginHandler&#40;userId, password&#41;&#41;;
teamRepository.login&#40;null&#41;;

IProcessClientService processClient= &#40;IProcessClientService&#41; teamRepository.getClientLibrary&#40;IProcessClientService.class&#41;;
IAuditableClient auditableClient= &#40;IAuditableClient&#41; teamRepository.getClientLibrary&#40;IAuditableClient.class&#41;;
IWorkItemClient workItemClient= &#40;IWorkItemClient&#41; teamRepository.getClientLibrary&#40;IWorkItemClient.class&#41;;

URI uri= URI.create&#40;projectAreaName.replaceAll&#40;&quot; &quot;, &quot;%20&quot;&#41;&#41;;
IProjectArea projectArea= &#40;IProjectArea&#41; processClient.findProcessArea&#40;uri, null, null&#41;;
if &#40;projectArea == null&#41; &#123;
System.out.println&#40;&quot;Project area not found.&quot;&#41;;
return false;
&#125;

IWorkItemType workItemType= workItemClient.findWorkItemType&#40;projectArea, typeIdentifier, null&#41;;
if &#40;workItemType == null&#41; &#123;
System.out.println&#40;&quot;Work item type not found.&quot;&#41;;
return false;
&#125;

List path= Arrays.asList&#40;categoryName.split&#40;&quot;/&quot;&#41;&#41;;
ICategoryHandle category= workItemClient.findCategoryByNamePath&#40;projectArea, path, null&#41;;
if &#40;category == null&#41; &#123;
System.out.println&#40;&quot;Category not found.&quot;&#41;;
return false;
&#125;

WorkItemInitialization operation= new WorkItemInitialization&#40;summary, category&#41;;
IWorkItemHandle handle= operation.run&#40;workItemType, null&#41;;
IWorkItem workItem= auditableClient.resolveAuditable&#40;handle, IWorkItem.FULL_PROFILE, null&#41;;
System.out.println&#40;&quot;Created work item &quot; + workItem.getId&#40;&#41; + &quot;.&quot;&#41;;

teamRepository.logout&#40;&#41;;

return true;
&#125;
&#125;

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.