Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
maxLevel3
minLevel3
typeflat
separatorpipe

Workflow functions

  1. Validator - check information from a CLI action before allowing a transition
  2. Post function - run a CLI action after the transition has completed

Usage

Administrator authority is required to add or update workflow actions. This is required to use the CLI plugin. 

  1. Create a draft workflow
  2. Edit the workflow
  3. Find the workflow step
  4. Select Validators or Post Functions tab
  5. Select Add
  6. Find and select CLI action

Parameter input dialog

CLI action validators and post functions share the same parameters.

  1. Product - select the product (JIRA, Confluence, Bamboo, Crucible, FishEye) to be accessed
  2. Action - provide an action string valid for the product selected - same as what you would do from a command line
  3. Data - some CLI actions can input data from standard input or using the file parameter and this allows the input data to be provided directly
    1. When using the file parameter, specify to use standard input: file -
  4. Find pattern1 - A regex pattern that is used to find data on the result produced by running the CLI action
    1. For a validator, if the pattern is not found, the validator will fail
    2. Regex find groups are available as substitution variables using syntax like pattern1_1pattern1_2, etc ...
  5. Find pattern2 - a second find pattern
    1. Regex find groups are available as substitution variables using syntax like pattern2_1pattern2_2, etc ...
  6. Message - Validator error message and workflow property value
    1. If validator fails (action fails or one of the find patterns do not match), this error message will be shown as a transition error
    2. Use text and substitution variables to construct a reasonable message
    3. For both validators and post functions, this message is passed as a workflow property for access in subsequent CLI actions
  7. Notes - This provides administrators an opportunity to better document this workflow function

Variable substitution

A variety of substitution variables are available to use in text parameters.

CategoryVariablesWhere UsedDiscussion
Issue special values

%issue_key%

%issue_summary%

%issue_description%

%issue_affected_versions%

%issue_fixed_versions%

Action, Data, Message

 
Parent issue special values

%parent_key%

%parent_summary%

%parent_description%

%parent_affected_versions%

%parent_fixed_versions%

Action, Data, MessageOnly available if issue is a subtask
Issue field values%fieldname%Action, Data, Message

Any JIRA defined field name.

Like components, resolution, dueDate, id

Issue custom field values%customfieldname%Action, Data, MessageIssue specific custom field name
CLI values

%base_url%

%validator_message%

%function_message%

Action, Data, Message

URL of this JIRA instance - useful for local JIRA actions

Message field from last run CLI action validator

Message field from last run CLI post function

Action result%cli_message%MessageResult message from running the CLI action

 

Logging

Advanced logging is available to provide an audit trail and help with problem determination. It is highly recommended that logging be enabled. To enable, add the following section or similar to your log4j.properties

No Format
titleAdd logging section to log4j.properties
# CLI action logging
log4j.appender.cliplugin=com.atlassian.jira.logging.MultiTenantJiraHomeAppender
log4j.appender.cliplugin.File=cli-plugin.log
log4j.appender.cliplugin.Threshold=INFO
log4j.appender.cliplugin.MaxFileSize=20480KB
log4j.appender.cliplugin.MaxBackupIndex=10
log4j.appender.cliplugin.layout=org.apache.log4j.PatternLayout
log4j.appender.cliplugin.layout.ConversionPattern=%d %p: %m%n

log4j.logger.org.swift.jira.acli.utilities.CliRunnerHelper.action=INFO, cliplugin
# set the following to true if you also want actions logged to the main jira log
log4j.additivity.org.swift.jira.acli.utilities.CliRunnerHelper.action=false
No Format
titleExample logging data
2012-07-18 07:46:24,404 INFO: 
Issue:     ZJCLIP-3
User:      admin
Context:   validator
Product:   JIRA
Action:    --action getFieldValue --issue ZJCLIP-3 --field priority --server http://imac2.local:8215 --user automation --password ***
Pattern:   value:\s+(\S+)
Pattern:   value:\s+((?:Critical)|(?:Blocker))
Result:    SUCCESS
           Issue ZJCLIP-3 has field 'priority' with value: 
Major (3)

Message:   This transition is only allowed for issues with Critical or Blocker priorities. The priority for this item is Major.

Image Removed

Image Removed

Image Removed

 

There are 2 primary ways to use this add-on.

  1. Workflow post function to run CLI actions on a transition - see CLI Post Function and CLI Validator

  2. Administrator UI for running CLI actions directly - see Administrator UI to Run CLI Actions

Related documentation

  • Action Reference - find product specific actions that you can run as part of the transition

Logging

Setting up advanced logging is highly recommended. See How to add advanced logging.

Security

CLI actions require user credentials to access Atlassian servers.  Those credentials must be provided on the action, there isn't currently any way to avoid that even with Application links. Consider setting up an automation account for CLI automation use.

Limitations

Actions like updateIssue and setFieldValue should not be used to update system fields if they reference the issue being transitioned. Instead, use post functions that are available for those specific functions directly. See JCLIP-19 for more information.