Jump to content

Custom integrations?


iceball12

Recommended Posts

Is there a way of creating my own bug tracking integration?

We are using our own bug tracking system and if we do go from svn to plastic we need the bug tracking system to be linked with plastic.

The extension API has been frozen since 2.7, so it's pretty stable now, but it's not yet documented.

It's already on our pipeline and we'll publish it on our website together with some more changes as soon as it's ready. It's a small API, so we'll publish the class reference and a few samples.

In the meantime, I'll copy here a small sample for your reference.

Cheers,

David

Link to comment
Share on other sites

As promised, here is a sample extension. It connects to a postgres database to retrieve the task data. This is the LoadTask method.

You need to reference the extensioncommon.dll assembly to build it. Basically you'll want to implement the methods in ITaskProvider (reflektor is your friend ;)

To use it, add an <Extensions> section to your client.conf pointing to your assembly. (Configure one extension from the gui and replace the entry created in client.conf with your assembly)

using System;
using System.Data;
using System.Drawing;
using System.Diagnostics;
using System.Collections;
using System.Windows.Forms;

using Codice.Client.Extension;

using Npgsql;
using log4net;

namespace Codice.Client.Extension
{

   public class TtsExtensionConfiguration : BaseExtensionConfiguration
   {
       public string User = "tts";
       public string Password = "tts";
       public string DatabaseConnectionString ="SERVER=192.168.1.2;PORT=5432;USER ID={0};PASSWORD={1};DATABASE=tts;ENCODING=UNICODE";
       public string TtsViewDefectUrl = "http://juno/tts/visualize.php?iddefect={0}";
   }

   internal class ConnectionFactory
   {
       public static IDbConnection GetConnection(TtsExtensionConfiguration config)
       {            
           IDbConnection result = new NpgsqlConnection(config.DatabaseConnectionString);

           result.Open();

           return result;
       }
   }

   public class TtsExtension: BasePlasticExtension
   {

       protected TtsExtensionConfiguration mConfig;
       protected IExtensionContainer mInstance;
       private static readonly ILog mLog = LogManager.GetLogger("extensions");

       private string mConfigFile = "druidextension.conf";

       public TtsExtension()
       {
           // Load config from disk
           mConfig = (TtsExtensionConfiguration) ExtensionServices.LoadConfig(mConfigFile, typeof(TtsExtensionConfiguration));
           if (mConfig == null)
               mConfig = new TtsExtensionConfiguration();

           mConfig.DatabaseConnectionString = String.Format(mConfig.DatabaseConnectionString, mConfig.User, mConfig.Password);            
           mConfig.SetDefaultAttributePrefix ("druid");
           mBaseConfig = mConfig;
       }

       #region Miembros de IPlasticExtension

       public override string GetName()
       {
           return "Druid TTS sample extension";
       }

       #endregion

       #region Miembros de ITaskProvider

       public override PlasticTask[] LoadTask (string[] ids, string repName)
       {
           if (ids[0] == null || ids[0] == String.Empty)
               return null;

           ArrayList result = new ArrayList();

           for (int i = 0; i < ids.Length; i++)
           {
               PlasticTask task = new PlasticTask();

               IDbConnection conn = ConnectionFactory.GetConnection(mConfig);

               try
               {
                   IDbCommand command = conn.CreateCommand();
                   command.CommandText = "SELECT d.iid, sheadline, s.sname as status, stext " + 
                       "FROM defect d, enclosure e, defectstatus s " + 
                       "WHERE d.iiddefectstatus = s.iid AND d.iid = e.iiddefect AND d.iid = " + ids[i];

                   IDataReader reader = command.ExecuteReader();

                   if (reader.Read())
                   {
                       task.Id = ids[i];
                       task.Title = (string)reader["sheadline"];
                       task.Description = (string)reader["stext"];
                       task.Owner = string.Empty;
                       task.Status = (string)reader["status"];
                   }
                   reader.Close();
               }
               catch (Exception ex)
               {
                   mLog.ErrorFormat("TTSExtension: {0}\n\t{1}", ex.Message, ex.StackTrace);
                   return null;
               }
               finally
               {
                   conn.Close(); 
               }

               result.Add(task);
           }

           return (PlasticTask[])result.ToArray(typeof (PlasticTask));

       }

       public override void OpenTask(string id, string repName)
       {
           System.Diagnostics.Process.Start(string.Format(mConfig.TtsViewDefectUrl, id) );
       }

       public bool Checkin(PlasticChangeset[] changesets)
       {
           return false;
       }

       #endregion
   }

}

Link to comment
Share on other sites

  • 6 months later...

Almost done linking our in house ticketing system to plastic using this sample. There are 2 differences

* Checkin function is not available in BasePlasticExtension which I currently use.

* I need to implement

Public Overrides Function GetTaskConfiguration(ByVal task As String) As PlasticTaskConfiguration()

What does this function need to return and what does the task parameter contain ?

Also another question :

Does 'LoadTask' need to return the taks in the same order as specified by the ids parameter ? If not the list of tasks can be queried using just 1 sqlcommand

Link to comment
Share on other sites

I've managed to get it working. Above issues where not the culprit.

I've implemented it as a generic issue tracker extension which uses 2 url parameters (1 for show task with id parameter, and one which gets ids=20,10,5 and returns xml with task details).

Would be a great standard extension as all ticketing system specific code does not reside in the actual extension dll

Link to comment
Share on other sites

Just as a remark, the GetTaskConfiguration is used by the Mylyn integration. Its purpose is to map a mylyn task id (the method argument) to the plastic repository, task id and branch prefix from the task tracker. You can safely ignore it if you are not using mylyn.

LoadTasks' order of the returned ids is not significant either.

And the Checkin method is really not needed there. It used to be part of the interface but it's not anymore. Actually it's not an override in the sample :). I should have removed it before posting.

Cheers,

David

Link to comment
Share on other sites

  • 7 months later...

What I need to do with this is add my bug tracking software to your "Issue Tracking" list in Options.

I want to be able to prefix a branch with "TP" and it would go to our TargetProcess server and get the Name for the Branch. I don't want to check in stuff I just want to see the name. Later I would like to be able to push the changeset file contents to TargetProcess so I see what files were changed in that User Story or Bug, and maybe later have TargetProcess click on that file and see the actual changes, but for now I would like to start with seeing the name and being able to click on it go to it in TargetProcess. Basically just like it works with FogBugz. Can I do that in 3.x or are we going to have to wait for release 4? Could really use some documentation even any at all would be great.

Link to comment
Share on other sites

To have your extension appear on the drop down, you can follow these steps:

- Create a file named "customextensions.conf' in the plastic client folder

- Add a line with this format:

Tracker name=path to extension DLL.

for instance:

Trac=extensions/trac/tracextension.dll

Cheers,

David

Link to comment
Share on other sites

hi there,

i wonder if it's possible to make custom extensions other than issue tracking ones?

i need to react on file/folder/workspace updates.

The OperationPlasticExtension class offers no such functionallity, or does it?

And another question is: Is it possible to manipulate the plastic gui via such extensions?

I need some buttons and such stuff.

regards,

Benjamin

Link to comment
Share on other sites

Hi manu,

thank you.

As we use a very special workflow, i would have added some buttons to do some smaller work automatically... no big deal.

BUT! It would be great to have a tree view in the branch explorer.

As we name our branches like this:

/Trunk

/Trunk/dev

/Trunk/dev/d0001

..

/Trunk/patch/

/Trunk/patch/p0002

...

/Trunk/feat/

/Trunk/feat/f0003

and so on...

To get back to my problem: where should i put a question about triggers in this forum?

Maybe you make some more extensions avaiable in version 4.0?!

Kind regards,

Benjamin

Link to comment
Share on other sites

We are using the Plastic - JIRA integration to log changeset info into a custom JIRA field (per the Plastic manuals, works great thanks!)

I was wondering if it would be possible to change the format of the data that gets pushed to JIRA on issue branches? Out-of-the-box that includes changeset number, author, repo, and list of files/directories. If possible, I'd like to add stuff like branch/revnos, time/date of checkin, etc. That would save having to cross-reference the changeset details in Plastic to get that info.

Thanks!

Dean

Link to comment
Share on other sites

We are using the Plastic - JIRA integration to log changeset info into a custom JIRA field (per the Plastic manuals, works great thanks!)

I was wondering if it would be possible to change the format of the data that gets pushed to JIRA on issue branches? Out-of-the-box that includes changeset number, author, repo, and list of files/directories. If possible, I'd like to add stuff like branch/revnos, time/date of checkin, etc. That would save having to cross-reference the changeset details in Plastic to get that info.

Thanks!

Dean

As an example, I wrote a trigger script to write a log of changesets. Basically it uses the cm log command, then writes the result to a log file in a format I specified with the --csFormat option. Here's a snippet of the result:

Changeset 15 created 8/19/2011 10:43:54 AM

(Repository: IASE_TDP Owner: daugustyniak Branch: /main/Word Merge)

Changed c:\PlasticCM\IASE_TDP\Docs\PSAC\SCMP Comments and Updates.xlsx (rev #1)

Changeset 14 created 8/19/2011 10:40:38 AM

(Repository: IASE_TDP Owner: daugustyniak Branch: /main)

Merged c:\PlasticCM\IASE_TDP\Docs\PSAC (rev #1)

Merged c:\PlasticCM\IASE_TDP\Docs\PSAC\SCMP Comments and Updates.xlsx (rev #0)

Changeset 13 created 8/19/2011 10:39:47 AM

(Repository: IASE_TDP Owner: daugustyniak Branch: /main/Word Merge)

Changed c:\PlasticCM\IASE_TDP\Docs\PSAC (rev #1)

Added c:\PlasticCM\IASE_TDP\Docs\PSAC\SCMP Comments and Updates.xlsx (rev #0)

If I could format the changeset logged in JIRA to something like the above, that would be great!

Thanks again!

Dean

Link to comment
Share on other sites

Hi deanaug,

Sorry but the format is not customizable by the user :(

I can discuss with the dev team if we can add more information such as the branch, I think that the

date is already inside, isn't it?

Is there any interesting field you feel that is missing?

Link to comment
Share on other sites

Hi Manu,

Date is NOT part of the data. Here's a (generic) example of what data is included:

Changeset <xxx> by <user> - (repository <repo>)

<Directories affected, name only no branch/revno>

<Files affected, name only no branch/revno>

Any/all of the fields in my previous post that could be also included would be helpful.

Thanks!!!

Dean

Link to comment
Share on other sites

  • 2 months later...

Having issue with our TargetProcess integration. Everything is working the extension shows up in the list and if I attach to the process the LoadTask method is called. The problem is ever id in the ids collection and the repname are all null and the string for repname is an empty string.

The issue can be seen in this screen shot: https://skydrive.liv...12B397B907F!143

Okay strike the request for this figured out it was the fact I set the attribute prefix and not the branch prefix.

Link to comment
Share on other sites

What version of the framework and and processor bit does the control need to be compiled under. Had the project working under my laptop which is running Windows 7 64 using the 3.5 Framework. Opened the project on my desktop and can't get a valid DLL to load in plastic. I have Plastic 3.0.187.16 running on my desktop and I have tried both 32 and 64 bit builds for 3.5 and 4.0 and none of them appear to work.

Give the error of "The format of the file 'TargetProcessExtension.dll' is invalid"

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...