As part of the Jenkow Jenkins Plugin which leverages the Activiti workflow engine for Jenkins job orchestration, I have added a new task type "Jenkins task" to the Activiti Modeler. Because unlike the Designer, the Modeler doesn't (yet) have a mechanism for incrementally adding new task types, I had to modify the Activiti code base. This Wiki page summarizes the changes I had to do. The enhanced Activiti code base is available on GitHub. My enhancement is done on top of Activiti 5.11.

My new task type is mapped onto the existing ServiceTask, using a custom task delegate class at run time.

It's good to take an existing task type as the starting point. User task or script task is a good choice.

The artwork

The new artwork went into modules/activiti-webapp-explorer2/src/main/webapp/editor/stencilsets/bpmn2.0/icons/jenkins.

New stencil

In modules/activiti-webapp-explorer2/src/main/resources/stencilset.json

Java Code

Declared a new stencil name constant in modules/activiti-json-converter/src/main/java/org/activiti/editor/constants/StencilConstants.java:

final String STENCIL_TASK_MYNEW = "MyNewTask";

The heavy lifting is done by a new class modules/activiti-json-converter/src/main/java/org/activiti/editor/language/json/converter/MyNewTaskJsonConverter.java. It is added to the existing converters in modules/activiti-json-converter/src/main/java/org/activiti/editor/language/json/converter/BpmnJsonConverter.java by calling MyNewTaskJsconConverter.fillTypes() in the static initializer. It's important to also add the stencil name into the right DI_... shape map, otherwise edges to the new stencil miss a waypoint.

DI_RECTANGLES.add(STENCIL_TASK_MYNEW);

Here, the method convertJsonToElement() is used to populate a ServiceTask model object which later gets converted into XML.

Added another element in the static initializer of the diagram generator modules/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/diagram/ProcessDiagramGenerator.java:

    // my new task
    activityDrawInstructions.put("myNewTask", new ActivityDrawInstruction() {
      public void draw(ProcessDiagramCanvas processDiagramCreator, ActivityImpl activityImpl) {
        processDiagramCreator.drawScriptTask((String) activityImpl.getProperty("name"), activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(),
                activityImpl.getHeight());
      }
    });

Import

Adding support for importing processes with a new task type is a bit more complicated in this case, because the Jenkins task is internally mapped to the Service Task.

I had to hard-code logic into the

As part of the Jenkow Jenkins Plugin which leverages the Activiti workflow engine for Jenkins job orchestration, I have added a new task type "Jenkins task" to the Activiti Modeler. Because unlike the Designer, the Modeler doesn't (yet) have a mechanism for incrementally adding new task types, I had to modify the Activiti code base. This Wiki page summarizes the changes I had to do. The enhanced Activiti code base is available on GitHub. My enhancement is done on top of Activiti 5.11.

My new task type is mapped onto the existing ServiceTask, using a custom task delegate class at run time.

It's good to take an existing task type as the starting point. User task or script task is a good choice.

The artwork

The new artwork went into modules/activiti-webapp-explorer2/src/main/webapp/editor/stencilsets/bpmn2.0/icons/jenkins.

New stencil

In modules/activiti-webapp-explorer2/src/main/resources/stencilset.json

Java Code

Declared a new stencil name constant in modules/activiti-json-converter/src/main/java/org/activiti/editor/constants/StencilConstants.java:

final String STENCIL_TASK_MYNEW = "MyNewTask";

The heavy lifting is done by a new class modules/activiti-json-converter/src/main/java/org/activiti/editor/language/json/converter/MyNewTaskJsonConverter.java. It is added to the existing converters in modules/activiti-json-converter/src/main/java/org/activiti/editor/language/json/converter/BpmnJsonConverter.java by calling MyNewTaskJsconConverter.fillTypes() in the static initializer. It's important to also add the stencil name into the right DI_... shape map, otherwise edges to the new stencil miss a waypoint.

DI_RECTANGLES.add(STENCIL_TASK_MYNEW);

Here, the method convertJsonToElement() is used to populate a ServiceTask model object which later gets converted into XML.

Added another element in the static initializer of the diagram generator modules/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/diagram/ProcessDiagramGenerator.java:

    // my new task
    activityDrawInstructions.put("myNewTask", new ActivityDrawInstruction() {
      public void draw(ProcessDiagramCanvas processDiagramCreator, ActivityImpl activityImpl) {
        processDiagramCreator.drawScriptTask((String) activityImpl.getProperty("name"), activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(),
                activityImpl.getHeight());
      }
    });

Import

Adding support for importing processes with a new task type is a bit more complicated in this case, because the Jenkins task is internally mapped to the Service Task.

I had to hard-code logic into the

As part of the Jenkow Jenkins Plugin which leverages the Activiti workflow engine for Jenkins job orchestration, I have added a new task type "Jenkins task" to the Activiti Modeler. Because unlike the Designer, the Modeler doesn't (yet) have a mechanism for incrementally adding new task types, I had to modify the Activiti code base. This Wiki page summarizes the changes I had to do. The enhanced Activiti code base is available on GitHub. My enhancement is done on top of Activiti 5.11.

My new task type is mapped onto the existing ServiceTask, using a custom task delegate class at run time.

It's good to take an existing task type as the starting point. User task or script task is a good choice.

The artwork

The new artwork went into modules/activiti-webapp-explorer2/src/main/webapp/editor/stencilsets/bpmn2.0/icons/jenkins.

New stencil

In modules/activiti-webapp-explorer2/src/main/resources/stencilset.json

Java Code

Declared a new stencil name constant in modules/activiti-json-converter/src/main/java/org/activiti/editor/constants/StencilConstants.java:

final String STENCIL_TASK_MYNEW = "MyNewTask";

The heavy lifting is done by a new class modules/activiti-json-converter/src/main/java/org/activiti/editor/language/json/converter/MyNewTaskJsonConverter.java. It is added to the existing converters in modules/activiti-json-converter/src/main/java/org/activiti/editor/language/json/converter/BpmnJsonConverter.java by calling MyNewTaskJsconConverter.fillTypes() in the static initializer. It's important to also add the stencil name into the right DI_... shape map, otherwise edges to the new stencil miss a waypoint.

DI_RECTANGLES.add(STENCIL_TASK_MYNEW);

Here, the method convertJsonToElement() is used to populate a ServiceTask model object which later gets converted into XML.

Added another element in the static initializer of the diagram generator modules/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/diagram/ProcessDiagramGenerator.java:

    // my new task
    activityDrawInstructions.put("myNewTask", new ActivityDrawInstruction() {
      public void draw(ProcessDiagramCanvas processDiagramCreator, ActivityImpl activityImpl) {
        processDiagramCreator.drawScriptTask((String) activityImpl.getProperty("name"), activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(),
                activityImpl.getHeight());
      }
    });

Import

Adding support for importing processes with a new task type is a bit more complicated in this case, because the Jenkins task is internally mapped to the Service Task.
I had to hard-code logic into modules/activiti-json-converter/src/main/java/org/activiti/editor/language/json/converter/ServiceTaskJsonConverter.java to get this mapping.
details