It's all about the answers!

Ask a question

Having problems while deploying a RTC Plugin on server side (Operation Participant)


Harsh Vardhan Singh (32410) | asked Mar 14 '16, 3:27 p.m.
edited Mar 14 '16, 3:29 p.m.
Hi Team,

I am new to creating plug-ins in RTC. I have created the following code using different jazz.net examples:



public class SendDatatoSlack implements IOperationParticipant {

    @Override
    public void run(AdvisableOperation operation,
            IProcessConfigurationElement participantConfig,
            IParticipantInfoCollector collector, IProgressMonitor monitor)
            throws TeamRepositoryException {
        // TODO Auto-generated method stub
       
        Object data = operation.getOperationData();
        ISaveParameter saveParameter = null;
        if (data instanceof ISaveParameter) {
            saveParameter = (ISaveParameter) data;
            /*
             * If the state id is new check for Defect with severity Blocker.
             */
            IWorkItem newState = (IWorkItem) saveParameter.getNewState();
            Identifier<IState> newStateId = newState.getState2();
            Identifier<IState> oldStateId = null;
            IWorkItem oldState = (IWorkItem) saveParameter.getOldState();
            String workItemtype= newState.getWorkItemType();
            String summary=newState.getHTMLSummary().getPlainText();
            String description= newState.getHTMLDescription().getPlainText();
            int workItemID= newState.getId();
            List<String> setTags= new ArrayList<String>();
            setTags.add("slack");
            setTags.add("notified");
            //String workItemURL= newState.g
           
            if(workItemtype.equals("com.ibm.team.workitem.workitemType.defect")){
                if (oldState != null){
                    // New work item check.
                    oldStateId = oldState.getState2();
                    if(newState.getSeverity().equals("severity.literal.l6")){
                       
                        convertToSlackPayloadandSend(workItemID,summary, description);
                        newState.setTags2(setTags);
                    }
                   
                }
                else if ((newStateId != null) && !(newStateId.equals(oldStateId))) {
                    /*
                     * If the work item is not of the proper type, do not build.
                     * Note that the work item type and state are hard coded, as is
                     * the build definition id. We will change that later. That is
                     * when we will start using the participantConfig parameter.
                     */
                   
                    if(newStateId.equals("com.ibm.team.workitem.defectWorkflow.state.s8")){
                       
                        convertToSlackPayloadandSend(workItemID,summary, description);
                        newState.setTags2(setTags);
                    }
                   
                }
            }
        }
           
}

            private void convertToSlackPayloadandSend(Integer id, String summary, String description ){
               
               
                StringBuilder texttobeSentonSlack= new StringBuilder("A new WorkItem has been created Id: ");
                texttobeSentonSlack.append(id.toString());
                texttobeSentonSlack.append(" Summary: ");
                texttobeSentonSlack.append(summary);
                texttobeSentonSlack.append(" Description : ");
                texttobeSentonSlack.append(description);
               
                //System.out.println("Text :" + texttobeSentonSlack);
               
                String s= String.format("curl -X POST --data-urlencode \"payload={\\\"channel\\\": \\\"#rtc_slack_test\\\", \\\"username\\\": \\\"rtc-incoming-webhook\\\", \\\"text\\\": \\\"%1$s\\\"}\" <<WebhookURL>>",texttobeSentonSlack );
               
                //System.out.println(s);
               
                try {
                    Runtime.getRuntime().exec(s);
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
           
                   
                   
            }
    }
   

Right now, everything is hardcoded like id's for defect and state. If this code works then I would work on parametrization part of this.

When I deploy this plug- in in RTC server side I am not able to see any "Follow- up Actions" added.

This is my folder structure:



and this is the contents for my profile.ini file for this plugin-

url=file:ccm/sites/rtc_slackexample-update-site
featureid=rtc_slack.example.feature

Can someone help on this?

One more question how can I get the URL for the WorkItems ? So, that I can use these URLs in the Operation participant operation?


Thanks!

Comments
sam detweiler commented Mar 14 '16, 4:19 p.m. | edited Mar 14 '16, 4:21 p.m.

If you are using eclipse, you need to close and reopen eclipse after you restart the server.. many times it will cache the list of plugins and not show you any changes..
and you must FORCE the server to reload, by using the request reset command
https://server:port/ccm/admin/cmd/requestReset, before restarting the server

can u show us your plugin.xml that describes this extension

>newState.setTags2(setTags);

after you modify the field, you must save the workitem again, but watch out, it will cause your plugin to be called again.. search on saveWorkitem3() here in the forums or Ralphs blog on how to pass info to that next invocation, informing it that it is YOU causing the save.

doesn't slack have an api you can call directly without having to invoke curl?


Donald Nong commented Mar 14 '16, 10:59 p.m.

This is the screenshot in the OP showing the folder structure.


sam detweiler commented Mar 14 '16, 11:37 p.m.

I have all my plugins in a separate folder, o that shouldn't be the problem. Of course we don't know what the ini files look like. 


Harsh Vardhan Singh commented Mar 30 '16, 8:05 a.m.

Thanks, team for your response!

I have used the server reset command as mentioned by you but due to some reason my RTC server on my local machine was not getting up.

So, I restarted my whole JTS server also but RTC was still not working.

I have reinstalled the RTC server and doing testing on a Jetty server.

Accepted answer


permanent link
Ralph Schoon (63.1k33645) | answered Mar 30 '16, 8:27 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Before even trying to deploy on a real server, follow https://rsjazz.wordpress.com/2015/09/30/learning-to-fly-getting-started-with-the-rtc-java-apis/ and setup your environment for debugging with Jetty.

If Jetty works you can try to deploy on a server. The extension workshop tells you how. Also see https://rsjazz.wordpress.com/2014/06/12/is-the-extension-deployed-how-can-i-redeploy/

If it does not work after deploying :
  • Check the CCM log - what error messages do you see
  • Check your dependencies and make sure not to have any client API referenced
  • You should have a Jazz Component, can you see that in the component status?
  • Did you deploy to CCM (and not accidentally into JTS?)

Unfortunately this step is really tough and the data above is insufficient. There is the site.xml, the feature project and more data that would be needed.

You don't get the URL for the work items. You could construct it however. It depends which URL you want. There are more than one representation.
Harsh Vardhan Singh selected this answer as the correct answer

One other answer



permanent link
Michele Pegoraro (1.8k14118103) | answered Mar 15 '16, 5:24 a.m.
Reasons for advisor/participant to not be seen could be mainly four, from my experience:
 - the plugin has not been properly provided
 - something is wrong with the plugin.xml
 - you've not restarted the eclipse client (as previously mentioned)
 - you've not asked for a server reset (as previously mentioned)

In order to find out if your plugin has been correctly provided you should take a look to the provisioning status:
https://host:port/ccm/admin?internal#action=com.ibm.team.repository.admin.provisionStatus

Here you should search for your update site and see when it has been loaded and if there are problems.

If everything is ok, you should check the plugin.xml, mainly the operation id you have used.


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.