-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refs/heads/feature/1180-workflows' into release/4.8
- Loading branch information
Showing
275 changed files
with
19,655 additions
and
2,654 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ target | |
.classpath | ||
.settings | ||
work*/ | ||
!workflows | ||
.DS_Store | ||
build | ||
.gradle | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
ontrack-common/src/main/java/net/nemerosa/ontrack/common/ExceptionUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package net.nemerosa.ontrack.common | ||
|
||
import org.apache.commons.lang3.exception.ExceptionUtils | ||
|
||
private const val MAX_STACK_HEIGHT = 20 | ||
private const val MAX_STACK_LENGTH = 2000 | ||
|
||
fun reducedStackTrace(error: Throwable) = | ||
ExceptionUtils.getStackFrames(error).take(MAX_STACK_HEIGHT).joinToString("\n").take(MAX_STACK_LENGTH) |
6 changes: 6 additions & 0 deletions
6
ontrack-docs/src/docs/asciidoc/appendix-workflow-node-executors.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[[appendix-workflow-node-executors]] | ||
=== Workflow nodes executors | ||
|
||
Find below the list of all workflow node executors and their configurations. | ||
|
||
include::workflow-node-executors/index.adoc[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
[[workflows]] | ||
=== Workflows | ||
|
||
Workflows allow the execution of several actions orchestrated in a DAG (directed acyclic graph). | ||
|
||
[NOTE] | ||
==== | ||
As of version 4.8, workflows can only be triggered using the <<notifications>>. | ||
There is already some partial and undocumented support through API calls to run some standalone workflows but this is very experimental. | ||
==== | ||
|
||
[[workflow-definitions]] | ||
==== Workflows definitions | ||
|
||
To run a workflow, you can define a notification whose channel is `workflow`. | ||
|
||
This can be done through the UI or as code. | ||
|
||
[NOTE] | ||
==== | ||
Workflows definitions in the UI is only supported in the Next UI of Ontrack and won't be supported in the legacy UI. | ||
==== | ||
|
||
A workflow: | ||
|
||
* has a name, used for information and display purposes | ||
* has a list of nodes | ||
|
||
Each node: | ||
|
||
* has an ID which must be unique inside the workflow | ||
* an executor ID that points to a _workflow node executor_ | ||
* some data for the _workflow node executor_ | ||
* a list of parent nodes | ||
|
||
The list of parent nodes is what defines the workflow DAG. | ||
|
||
[NOTE] | ||
==== | ||
When defining or running workflows, graph cycles are automatically detected. | ||
==== | ||
|
||
Workflows notifications can be defined as code, like all other <<notifications,notifications>>. | ||
|
||
For example: | ||
|
||
[source,yaml] | ||
---- | ||
channel: workflow | ||
channelConfig: | ||
workflow: | ||
name: My workflow | ||
nodes: | ||
- id: ticket | ||
executorId: notification | ||
data: | ||
channel: jira-creation | ||
channelConfig: | ||
# Configuration for the ticket creation | ||
- id: mail | ||
executorId: notification | ||
parents: | ||
- id: ticket | ||
data: | ||
channel: mail | ||
channelConfig: | ||
# Configuration for the mail | ||
template: | | ||
Link to ticket: ${workflow.ticket?path=url} | ||
---- | ||
|
||
[[workflow-executors]] | ||
==== Workflows nodes executors | ||
|
||
A _workflow node executor_ is a component which is responsible to "run a node". | ||
|
||
See <<appendix-workflow-node-executors>> for a list of all existing workflow node executors. | ||
|
||
[[workflow-templates]] | ||
==== Workflow templating | ||
|
||
Many elements in the workflow definition are subject to <<appendix-templating,templating>>. | ||
|
||
The workflow name is itself considered as a template when being run as a notification (which is the default in 4.8). | ||
|
||
When using <<workflow-node-executor-notification,notifications as node executors>>, the configuration elements are templates as usual. | ||
|
||
Note that for a workflow notification, the event is passed as a context element and all template functions and sources are available. | ||
|
||
Additionally, when a notification is run as part of a workflow, a new templating function is available: `workflow`. | ||
|
||
This function allows the access to the output data of any successful node in the workflow. | ||
|
||
For example, let's take a workflow which: | ||
|
||
* creates a ticket in Jira | ||
* then send a link to this ticket with an email | ||
|
||
|
||
|
||
[source,yaml] | ||
---- | ||
channel: workflow | ||
channelConfig: | ||
workflow: | ||
name: My workflow | ||
nodes: | ||
- id: ticket | ||
executorId: notification | ||
data: | ||
channel: jira-creation | ||
channelConfig: | ||
# Configuration for the ticket creation | ||
- id: mail | ||
executorId: notification | ||
parents: | ||
- id: ticket | ||
data: | ||
channel: mail | ||
channelConfig: | ||
# Configuration for the mail | ||
template: | | ||
Link to ticket: ${workflow.ticket?path=url} | ||
---- | ||
|
||
The `ticket` node runs and set some information in its output (see <<notification-backend-jira-creation>> for the full details), including a `url` property. | ||
|
||
Then, the `mail` node is run and is using the `notification` _workflow node executor_ again, with the <<notification-backend-mail,`mail` channel>> being configured to send a mail. | ||
|
||
This channel can use the `template` for the mail's body and is using the `workflow` function to get the output of the `ticket` node and the `url` property of its output. | ||
|
||
[[workflow-management]] | ||
==== Workflows management | ||
|
||
The progress of running workflows can be accessed in _Information > Workflow audit_. | ||
|
||
Clicking on a workflow displays more details about its current status, node per node. | ||
|
||
When using the _workflow notification channel_, the workflow status link is also accessible from the _Information > Notification recordings_, when selecting the notification. | ||
|
||
[[workflow-settings]] | ||
==== Workflows settings | ||
|
||
Workflow statuses are saved by default for 14 days. | ||
|
||
To change this value, you can go to _System > Settings > Workflows_. | ||
|
||
This can also be defined as code using <<casc,CasC>>: | ||
|
||
[source,yaml] | ||
---- | ||
ontrack: | ||
config: | ||
settings: | ||
workflows: | ||
retentionDuration: 1209600000 # 14 days in ms | ||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
ontrack-docs/src/docs/asciidoc/notifications/notification-backend-workflow.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[[notification-backend-workflow]] | ||
==== Workflow (`workflow`) | ||
|
||
Launches a workflow | ||
|
||
|
||
|
||
_This channel does not use the custom template._ | ||
|
||
Configuration: | ||
|
||
* **workflow** - Object - required - Workflow to run | ||
|
||
** **name** - String - required - Display name for the workflow | ||
|
||
** **nodes** - List - required - List of nodes in the workflow | ||
|
||
*** **data** - JSON - required - Raw data associated with the node, to be used by the node executor. | ||
|
||
*** **executorId** - String - required - ID of the executor to use | ||
|
||
*** **id** - String - required - Unique ID of the node in its workflow. | ||
|
||
*** **parents** - List - required - List of the IDs of the parents for this node | ||
|
||
**** **id** - String - required - ID of the parent node | ||
|
||
Output: | ||
|
||
* **workflowInstanceId** - String - required - ID of the workflow instance. Can be used to track the progress and outcome of the workflow. | ||
|
8 changes: 8 additions & 0 deletions
8
ontrack-docs/src/docs/asciidoc/workflow-node-executors/index.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[[appendix-workflow-node-executors-index]] | ||
==== List of workflow node executors | ||
|
||
* <<workflow-node-executor-mock,Mock (mock)>> | ||
* <<workflow-node-executor-notification,Notification (notification)>> | ||
|
||
include::workflow-node-executor-mock.adoc[] | ||
include::workflow-node-executor-notification.adoc[] |
27 changes: 27 additions & 0 deletions
27
...docs/src/docs/asciidoc/workflow-node-executors/workflow-node-executor-mock.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[[workflow-node-executor-mock]] | ||
==== Mock (mock) | ||
|
||
Executor used to mock some actions for the nodes. Mostly used for testing. | ||
|
||
Configuration: | ||
|
||
* **error** - Boolean - required - Raising an error during the execution of the node | ||
|
||
* **text** - String - required - Text associated with the node | ||
|
||
* **waitMs** - Long - required - Time to wait for the execution of the node | ||
|
||
Output: | ||
|
||
* **text** - String - required - text field | ||
|
||
Example: | ||
|
||
[source] | ||
---- | ||
executorId: mock | ||
data: | ||
text: Some text to store | ||
waitMs: 500 | ||
error: false | ||
---- |
28 changes: 28 additions & 0 deletions
28
.../docs/asciidoc/workflow-node-executors/workflow-node-executor-notification.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[[workflow-node-executor-notification]] | ||
==== Notification (notification) | ||
|
||
Wraps a notification in a workflow node. | ||
|
||
The output of this execution is exactly the output | ||
of the notification channel. | ||
|
||
Configuration: | ||
|
||
* **channel** - String - required - Notification channel ID | ||
|
||
* **channelConfig** - JSON - required - Notification channel configuration | ||
|
||
* **template** - String - optional - Optional template for the notification | ||
|
||
Example: | ||
|
||
[source] | ||
---- | ||
executorId: notification | ||
data: | ||
channel: slack | ||
channelConfig: | ||
channel: "#my-channel" | ||
template: | | ||
Message template | ||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.