It's all about the answers!

Ask a question

Writing a new Build Engine...


Andrew Harmel-Law (14612218) | asked Sep 27 '09, 7:06 a.m.
retagged May 15 '13, 8:09 a.m. by Morten Madsen (3053250)
Hi there,

I'm looking into writing my own build engine. I have a few questions I hope someone can help me with. They are as follows:

1. I can get my engine to see when a build has been requested and whether it is a scheduled or a personal one. What I want to do however is load the correct workspace if its a personal request. Can I obtain this information from the BuildRequest and if so how?

2. I want to be able to create a change log file from any changes in a build. I can see the change handles (ChangeSetInfo) but I would like to get the actual change details from these. I'm guessing it's not hard, but I can't see how.

That's it for now. I hope someone can help.

Thanks in advance.

Cheers, Andrew

11 answers



permanent link
Nick Edgar (6.5k711) | answered Sep 29 '09, 2:32 p.m.
JAZZ DEVELOPER
Hi Andrew,

Could you clarify why you want to write your own build engine? Note that JBE is extensible, so you could add your own pre-build/build/post-build participants instead, which could save you a lot of work. Can you describe what you're trying to do at a higher level?

But to answer your questions:

1.
What I want to do however is load the correct workspace if its a personal request. Can I obtain this information from the BuildRequest and if so how?


The corresponding code in JBE is in com.ibm.team.build.internal.engine.JazzScmPreBuildParticipant. To get the workspace item id, it does:

IBuildProperty property ...;
...
property = getBuildRequest().getBuildDefinitionInstance().getProperty(
IJazzScmConfigurationElement.PROPERTY_WORKSPACE_UUID);
if (property != null && property.getValue().length() > 0) {
...

Where getBuildRequest() is the IBuildRequest for the requested build, given in the participant's initializer.

IJazzScmConfigurationElement.PROPERTY_WORKSPACE_UUID is:
    public static final String PROPERTY_WORKSPACE_UUID = "team.scm.workspaceUUID";



2.
I can see the change handles (ChangeSetInfo) but I would like to get the actual change details from these.

What kind of details do you want? The structure of the change set, the associated work item(s), or both? For getting the associated work items, take a look at the code for com.ibm.team.build.internal.publishing.WorkItemPublisher.publish(IBuildResultHandle, IWorkItemHandle[], ITeamRepository), and its getWorkItemHandles method. The latter does:

for (int i = 0; i < changeSetHandles.length; i++) {
IChangeSetHandle changeSetHandle = changeSetHandles[i];

List<ILink> links = ChangeSetLinks.findLinks(
(ProviderFactory) teamRepository.getClientLibrary(ProviderFactory.class), changeSetHandle,
new NullProgressMonitor());

for (ILink link : links) {
IReference targetRef = link.getTargetRef();

if (targetRef.isItemReference()
&& ((IItemReference) targetRef).getReferencedItem() instanceof IWorkItemHandle) {

IWorkItemHandle workItemHandle = (IWorkItemHandle) ((IItemReference) targetRef).getReferencedItem();
// Need to use a HashTable in this way instead of a
// HashSet because we may have distinct work item
// handles, but
// they are pointing at the same uuidValue. We don't
// want to
// add handles with the same uuidValue.
workItemHandles.put(workItemHandle.getItemId().getUuidValue(), workItemHandle);
}
}
}

Where ChangeSetLinks is helper API in SCM: com.ibm.team.scm.common.links.ChangeSetLinks.

You could also use:

com.ibm.team.scm.client.SCMPlatform.getWorkspaceManager().getChangeSetLinkSummary(changeSetHandles, progressMonitor)


Regards,
Nick

permanent link
Andrew Harmel-Law (14612218) | answered Oct 03 '09, 6:10 a.m.
Hi Nick, thanks for your very detailed answer

Hi Andrew,

Could you clarify why you want to write your own build engine? Note that JBE is extensible, so you could add your own pre-build/build/post-build participants instead, which could save you a lot of work. Can you describe what you're trying to do at a higher level?


Its partially a personal exercise, and partially driven by necessity. I want to use Hudson as my build engine on a project. This is due to the complexity of the architecture - we'll need to build java, msft and PL/SQl code, run all kinds of static analysis tools, and deploy and test across a VM environment. Hudson has support for all this out of the box. What Hudson doesn't (yet) have is support for Jazz. I want to solve that.


But to answer your questions:

1.
What I want to do however is load the correct workspace if its a personal request. Can I obtain this information from the BuildRequest and if so how?


The corresponding code in JBE is in com.ibm.team.build.internal.engine.JazzScmPreBuildParticipant. To get the workspace item id, it does:

IBuildProperty property ...;
...
property = getBuildRequest().getBuildDefinitionInstance().getProperty(
IJazzScmConfigurationElement.PROPERTY_WORKSPACE_UUID);
if (property != null && property.getValue().length() > 0) {
...

Where getBuildRequest() is the IBuildRequest for the requested build, given in the participant's initializer.

IJazzScmConfigurationElement.PROPERTY_WORKSPACE_UUID is:
    public static final String PROPERTY_WORKSPACE_UUID = "team.scm.workspaceUUID";



Thanks. That makes sense. I'll give it a try.


2.
I can see the change handles (ChangeSetInfo) but I would like to get the actual change details from these.

What kind of details do you want? The structure of the change set, the associated work item(s), or both?

Its both I'm looking for I think. To fully implement a Hudson SCM plugin I will need to get a hold of the full change set details and parse them so Hudson can get to grips with them.

Thanks again for this. I think this will help me get a handle on what I need. The hard part then will be translating it for Hudson.


For getting the associated work items, take a look at the code for com.ibm.team.build.internal.publishing.WorkItemPublisher.publish(IBuildResultHandle, IWorkItemHandle[], ITeamRepository), and its getWorkItemHandles method. The latter does:

for (int i = 0; i < changeSetHandles.length; i++) {
IChangeSetHandle changeSetHandle = changeSetHandles[i];

List<ILink> links = ChangeSetLinks.findLinks(
(ProviderFactory) teamRepository.getClientLibrary(ProviderFactory.class), changeSetHandle,
new NullProgressMonitor());

for (ILink link : links) {
IReference targetRef = link.getTargetRef();

if (targetRef.isItemReference()
&& ((IItemReference) targetRef).getReferencedItem() instanceof IWorkItemHandle) {

IWorkItemHandle workItemHandle = (IWorkItemHandle) ((IItemReference) targetRef).getReferencedItem();
// Need to use a HashTable in this way instead of a
// HashSet because we may have distinct work item
// handles, but
// they are pointing at the same uuidValue. We don't
// want to
// add handles with the same uuidValue.
workItemHandles.put(workItemHandle.getItemId().getUuidValue(), workItemHandle);
}
}
}

Where ChangeSetLinks is helper API in SCM: com.ibm.team.scm.common.links.ChangeSetLinks.

You could also use:

com.ibm.team.scm.client.SCMPlatform.getWorkspaceManager().getChangeSetLinkSummary(changeSetHandles, progressMonitor)


Regards,
Nick


Thankyou very much for all this help. I'll post how I get on to this thread for the benefit of others.

Cheers, Andrew

permanent link
Nick Edgar (6.5k711) | answered Oct 03 '09, 1:32 p.m.
JAZZ DEVELOPER
Andrew, note that for integration with Hudson, you can do the workspace accept and fetch (aka load) phases using the Ant tasks in our Build Toolkit, as well as contribute compilation and test results, downloads, logs, etc. back to the RTC build definition as is normally done.

We have an article coming out shortly showing exactly how to do this (using Hudson).

But it sounds like you're aiming for an even tighter integration with Hudson, at least for the SCM portion of the build. I'm definitely interested in this, so please let me know how it goes. We also want to provide this kind of support for Maven. See 90042: Maven SCM plugin extension for RTC.

permanent link
Nick Edgar (6.5k711) | answered Oct 03 '09, 1:34 p.m.
JAZZ DEVELOPER
To clarify further, there are also Ant tasks for kicking off the RTC build (i.e. issuing the build request and completing it), to enable the build to be orchestrated by some other build system like Hudson. The article shows how to do this. For more on the Ant toolkit tasks, see:
https://jazz.net/wiki/bin/view/Main/BuildFAQ#BuildSystemToolkitContents

permanent link
Andrew Harmel-Law (14612218) | answered Oct 04 '09, 5:20 a.m.
Hi Nick,

I'd originally looked at the ANT API but wanted to keep the control from the Jazz server end (I and my team are bigs fans of personal builds) so I realised I needed something more. Like you say, "even tighter integration". Its looking like I'll need to write both a Hudson and a Build Template plugin to really achieve this but that's not a problem - its fun.

However, I've see the link you sent me which is great. I'll definately set this up in the interim (I don't want to bet my project on my as-yet not really tested Hudson plugin code.)

Andrew, note that for integration with Hudson, you can do the workspace accept and fetch (aka load) phases using the Ant tasks in our Build Toolkit, as well as contribute compilation and test results, downloads, logs, etc. back to the RTC build definition as is normally done.

We have an article coming out shortly showing exactly how to do this (using Hudson).

But it sounds like you're aiming for an even tighter integration with Hudson, at least for the SCM portion of the build. I'm definitely interested in this, so please let me know how it goes. We also want to provide this kind of support for Maven. See 90042: Maven SCM plugin extension for RTC.


I'll check out the Maven link. It sounds very interesting. I'd like to be able to do this too and that was going to be one of my next ports of call (as well as a Netbeans plugin and a SCM client similar to Tortoise - so our BAs and PM's can check in and out withut having to face the complexity "hell" of a developer IDE.) Actually, if you know of anything in these spaces let me know as I'd ben keen to contribute.

Thanks again. Regs, Andrew

permanent link
Nick Edgar (6.5k711) | answered Oct 05 '09, 10:15 a.m.
JAZZ DEVELOPER
I'm not aware of any work on either a Netbeans integration or a Tortoise-like non-IDE client for Jazz SCM, but you should check out the work on making certain non-developer scenarios accessible via the web UI (planned for 2.0.0.2).

See:
87245: simple web ui for modifying streams / WES for streams
and also
87338: SCM Web UI post 2.0 work and investigation
and
87336: SCM Web UI post 2.0 - better integration with Build web ui? and its related items.

The SCM command line is also an option.

Regards,
Nick

permanent link
Andrew Harmel-Law (14612218) | answered Oct 10 '09, 5:24 a.m.
That (a simple Web UI) would be excellent. We have 3 BA's on this project who want to keep their UML models in Jazz SCM and I currently have to teach them how to use the Eclipse Client - it feels like overkill for their requirements. A simple Web UI for this would be ideal.

Perhaps its only the Netbeans plugin I'll have to work on...

Regs, Andrew

I'm not aware of any work on either a Netbeans integration or a Tortoise-like non-IDE client for Jazz SCM, but you should check out the work on making certain non-developer scenarios accessible via the web UI (planned for 2.0.0.2).

See:
87245: simple web ui for modifying streams / WES for streams
and also
87338: SCM Web UI post 2.0 work and investigation
and
87336: SCM Web UI post 2.0 - better integration with Build web ui? and its related items.

The SCM command line is also an option.

Regards,
Nick

permanent link
Peter Hendriks (2611) | answered Oct 26 '09, 12:57 p.m.
We have an article coming out shortly showing exactly how to do this (using Hudson).
It would be very nice if you could e-mail/publish a draft of this article. We are investigating this as well and this would be very helpful information!

permanent link
Andrew Harmel-Law (14612218) | answered Oct 26 '09, 12:59 p.m.
Hi Peter,

I'll hopefully have my 0.1 hudson plugin ready soon and hopefully the code will follow shortly after. If you'd ilke to help me with the development / testing of this let me know as any niput would be gratefully recieved.

We have an article coming out shortly showing exactly how to do this (using Hudson).
It would be very nice if you could e-mail/publish a draft of this article. We are investigating this as well and this would be very helpful information!

Cheers, Andrew

permanent link
Nick Edgar (6.5k711) | answered Oct 27 '09, 3:12 p.m.
JAZZ DEVELOPER
The article on integrating between Hudson and RTC Build is now published at http://jazz.net/library/article/350

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.