KBEC-00337 - How to run and debug postp from command line

Article ID:360033190351
2 minute readKnowledge base

Summary

It can be tedious and time-consuming to re-run jobs over and over just to test postp matching. How can I do this in a more efficient manner?

Solution

postp can be run from the command line and matched against text in a file on any machine that has a CloudBees CD (CloudBees Flow) server, agent, or tools only installation.

Examples

You can run postp --help to confirm that postp is installed and get a list of available options for the command.

postp requires a jobStepId on which to operate so that it knows where to put the results of the diagnostics info that it extracts. For debug and testing purposes, you can use any jobStepId.

To debug your postp matchers, create a file with text for it to match against. For example, I created test.txt with the following contents:

warning: this is a test
error: test failure

Then run:

postp --printUpdates --jobStepId <any_existing_stepId> --debugLog postp.log < test.txt

With the --printUpdates option, the server update message will be printed to standard output. This message gives you a summary of how many errors and warnings postp has found, as well as the outcome flag:

<?xml version="1.0" encoding="UTF-8"?>
<requests xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceS
chemaLocation="commander.xsd" version="2.0" sessionId="IJQJEJBRRUL89LQR">
<request requestId="1">
<setProperty>
<jobStepId>2659</jobStepId>
<propertyName>charEncoding</propertyName>
<value>cp437</value>
</setProperty>
</request>
<request requestId="2">
<setProperty>
<jobStepId>2659</jobStepId>
<propertyName>diagFile</propertyName>
<value>diag-2659.xml</value>
</setProperty>
</request>
<request requestId="3">
<setProperty>
<jobStepId>2659</jobStepId>
<propertyName>errors</propertyName>
<value>1</value>
</setProperty>
</request>
<request requestId="4">
<setProperty>
<jobStepId>2659</jobStepId>
<propertyName>outcome</propertyName>
<value>error</value>
</setProperty>
</request>
<request requestId="5">
<setProperty>
<jobStepId>2659</jobStepId>
<propertyName>warnings</propertyName>
<value>1</value>
</setProperty>
</request>
</requests>

You can look in postp’s debug log for more details about what postp is matching. Here is a partial example of the postp debug log from our previous command:

5/27/2015 16:50:51 Postp starting
5/27/2015 16:50:51 step-id: 2659
5/27/2015 16:50:51 Set property charEncoding to "cp437"
5/27/2015 16:50:51 Scanning line 1: warning: this is a test
5/27/2015 16:50:51 Line matched by warning
5/27/2015 16:50:51 Set property warnings to "1"
5/27/2015 16:50:51 Incrementing warnings to 1
5/27/2015 16:50:51 Set property diagFile to "diag-2659.xml"
5/27/2015 16:50:51 Diagnostic generated for lines 1-1, matcher: warning, name: , type: warning
5/27/2015 16:50:51 Diagnostic generated for lines 1-1, name: , type: warning
5/27/2015 16:50:51 Set property outcome to "warning"
5/27/2015 16:50:51 Updating server, urgent: 1

Applies to

  • Product versions: All

  • OS versions: All