buildframework/helium/sf/java/signaling/signaling.rst
author wbernard
Tue, 27 Apr 2010 08:33:08 +0300
changeset 587 85df38eb4012
child 588 c7c26511138f
permissions -rw-r--r--
helium_9.0-a7879c935424
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     1
=====================
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     2
Configuring Signaling
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     3
=====================
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     4
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     5
Helium signaling framework offers you a simplest way to control 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     6
failures on build flow, and provides you an easy way to get reporting on
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     7
some crucial steps of your build.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     8
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     9
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    10
The configuration
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    11
-----------------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    12
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    13
The signaling configuration is divided on three parts:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    14
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    15
   * the signalListenerConfig: defines the signal
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    16
   * the signalInput: defines what to do when a signal is raised
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    17
   * the notifierList: defines a set of notifiers
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    18
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    19
signalListenerConfig
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    20
....................
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    21
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    22
This part of the configuration is not targeted to be overridden by the build manager.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    23
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    24
The following example defines a custom signal named as **customSignal**.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    25
The default configuration must reference a default signalInput configuration using a nested inputRef element,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    26
so the signaling framework knows how to behave when a signal is raised.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    27
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    28
.. code-block:: xml
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    29
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
    <hlm:signalListenerConfig id="customSignal" target="target-name" message="target-name triggered a signal">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
        <signalNotifierInput>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
            <signalInput refid="signalInputId" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    33
            <notifierInput file="some/file/to/notify.html" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    34
        </signalNotifierInput>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
        <hlm:targetCondition>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
            </available file="some-file.txt" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
        </hlm:targetCondition>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    38
    </hlm:signalListenerConfig>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
A signal will then be triggered each time the **target-name** completed. The signalInput will then defined how it should be handled.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
Other way to trigger a signal is by using the signal task:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
.. code-block:: xml
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    45
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
    <hlm:signal name="customSignal" result="1">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    47
        <signalNotifierInput>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    48
            <signalInput refid="signalInputId" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
            <notifierInput file="some/file/to/notify.html" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    50
        </signalNotifierInput>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    51
    </hlm:signal>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    53
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    54
signalInput
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    55
...........
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    56
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    57
This Ant type defines what a signal should do when it is raised. The failbuild attribute defines
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    58
if a build failure should be:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    59
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    60
    * failing the build now (value: now)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    61
    * deferred at the end of the build (value: defer)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    62
    * ignored (value: never)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    63
   
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    64
Then the configuration will accept a reference to a notifierList using the notifierListRef element.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    65
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    66
Example of configurations
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    67
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    68
.. code-block:: xml
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    69
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    70
    <hlm:signalInput id="customSignalInput" failbuild="now">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    71
        <hlm:notifierListRef refid="customNotifier" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    72
    </hlm:signalInput>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    73
  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    74
This will run all notifier from the customNotifier configuration then fail the build.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    75
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    76
.. code-block:: xml
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    77
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    78
    <hlm:signalInput id="customSignalInput" failbuild="defer"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    79
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    80
This will defer the failure at the end of the build, no notifier will be run.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    81
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    82
notifierList
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    83
............
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    84
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    85
The notifierList Ant type allows the user to configure a set of Notifier (e.g Email, execute task):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    86
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    87
The following example configures a notifier list that will send an email and run few echo task to print
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    88
some information.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    89
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    90
.. code-block:: xml
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    91
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    92
    <hlm:notifierList id="customNotifier">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    93
        <hlm:emailNotifier templateSrc="${helium.dir}/tools/common/templates/log/email_new.html.ftl"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    94
                           title="[signal] ${signal.name}" smtp="smtp.server.address"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    95
                           ldap="ldap://ldap.server.address:389"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    96
                           notifyWhen="always"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    97
        <hlm:executeTaskNotifier>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    98
            <echo>defaultSignalAlwaysNotifier: Signal: ${signal.name}</echo>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    99
            <echo>defaultSignalAlwaysNotifier: Status: ${signal.status}</echo>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   100
        </hlm:executeTaskNotifier>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   101
    </hlm:notifierList>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   102
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   103
Detailed documentation of the notifier interface could be found `here <../../helium-antlib/index.html>`_.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   104
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   105
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   106
Example: configuring compileSignal
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   107
----------------------------------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   108
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   109
In this example we will configure the compileSignal to behave this way:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   110
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   111
   * send an email to additional users e.g: user@foo.com, user@bar.com
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   112
   * defer the build failure.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   113
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   114
You configuration should contains (e.g build.xml)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   115
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   116
.. code-block:: xml
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   117
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   118
   <?xml version="1.0"?>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   119
   <project name="mybuild">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   120
      ...
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   121
      <import file="${helium.dir}/helium.ant.xml"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   122
      ...
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   123
      
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   124
      <hlm:notifierList id="myCustomNotifierList">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   125
          <hlm:emailNotifier templateSrc="${helium.dir}/tools/common/templates/log/email_new.html.ftl"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   126
                title="[signal] My build goes wrong: ${signal.name}"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   127
                smtp="${email.smtp.server}"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   128
                ldap="${email.ldap.server}"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   129
                notifyWhen="fail"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   130
                additionalrecipients="user@foo.com,user@bar.com"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   131
      </hlm:notifierList>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   132
      
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   133
      <hlm:signalInput id="compileSignalInput" failbuild="defer">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   134
         <hlm:notifierListRef refid="myCustomNotifierList" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   135
      </hlm:signalInput>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   136
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   137
   </project>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   138
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   139
   
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   140
A custom notifierList has been created with **myCustomNotifierList** as reference ID. It defines
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   141
a emailNotifier which uses the default email template under Helium (${helium.dir}/tools/common/templates/log/email_new.html.ftl).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   142
It also set the title of you email to be "[signal] My build goes wrong: ${signal.name}" (signal.name property will be replace by the signal name raised).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   143
**notifyWhen** attribute will make the notifier to send a notification only on build failure.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   144
Finally the two additional email addresses will be set using the **additionalrecipients** attribute. 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   145
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   146
We then need to link the signal configuration and our custom the notifier list. The signalInput element is use to achieve that. 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   147
It must be defined using the same reference ID (see reference overriding howto) as the one in the Helium configuration, the naming convention for this is: **<signal_name>Input**.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   148
Its **failbuild** attribute is set to **defer** which will configure the build to keepgoing, and fail at the end of the build flow.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   149
Finally an embedded notifierListRef element will reference our custom notifier list: **myCustomNotifierList**.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   150
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   151
While failing the signaling framework will execute all notifier defined and then store internally the build failure so it can raise it again at the end of the execution.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   152
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   153
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   154
Example: Report specific errors not included by default
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   155
-------------------------------------------------------
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   156
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   157
Target prep-work-area has extra log extraction added and output xml is read by a new signal.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   158
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   159
.. code-block:: xml
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   160
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   161
   <hlm:signalInput id="prepWorkAreaSignalInputWarn" failbuild="defer">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   162
       <hlm:notifierListRef refid="defaultSignalFailNotifier" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   163
   </hlm:signalInput>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   164
   
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   165
   <hlm:signalListenerConfig id="prepWorkAreaSignalWarn" target="prep-work-area" message="Warnings happened during Preparing Work Area">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   166
        <signalNotifierInput>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   167
            <signalInput refid="prepWorkAreaSignalInputWarn" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   168
            <notifierInput file="${build.log.dir}/${build.id}_ccm_get_input.log2.xml" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   169
        </signalNotifierInput>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   170
       <hlm:targetCondition> 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   171
           <hlm:hasSeverity severity="error" file="${build.log.dir}/${build.id}_ccm_get_input.log2.xml"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   172
       </hlm:targetCondition>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   173
   </hlm:signalListenerConfig>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   174
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   175
   <target name="prep-work-area" depends="ccmgetinput.prep-work-area">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   176
       <hlm:logextract file="${prep.log.dir}/${build.id}_ccm_get_input.log" outputfile="${build.log.dir}/${build.id}_ccm_get_input.log2.xml">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   177
           <recordfilterset>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   178
               <recordfilter category="error" regexp=".*Explicitly specified but not included" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   179
           </recordfilterset>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   180
       </hlm:logextract>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   181
   </target>