Maven plugin
The Step Maven plugin serves as Command Line Interface (CLI) for all operations related to Automation Packages in Java. It provides an integration with the Step server and an easy way to integrate Step with a CI/CD pipeline. For non-Java projects, it is recommended to use the Step CLI.
The Step Maven plugin supports following operations:
- Upload Automation Packages to Step and execute them in isolation
- Deploy the content of Automation Packages to Step and enable the contained schedules
For compatibility reason it still supports following operation for the legacy Keyword packages
- Deploy Keyword Packages to Step (deprecated)
You can choose to integrate the plugin goals during the package
phase or any later phase as you see fit in the Maven Lifecycle.
Integration
To include the Step plugin in your project you need to add the appropriate dependency to the <pluginManagement>
section in your pom.xml
.
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>ch.exense.step</groupId>
<artifactId>step-maven-plugin</artifactId>
<version>${step.plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
You can list the available plugin goals by calling the following command (in the folder of a maven project including the step-maven-plugin
):
mvn step:help
To display the parameters of some plugin goal you can use the following command:
mvn step:help -Ddetail=true -Dgoal=goal-name
Once you have declared the plugin in the <pluginManagement>
section, you can use it as any common Maven plugin: call a plugin goal directly from the command line, or bind a goal to a phase of the maven lifecycle (using the <plugins>
section of the pom.xml
file).
Integration with Step Enterprise Edition
The maven plugin supports the following optional features which are required to communicate with Step Enterprise, but should be left empty for Step Open Source:
- Authentication: the plugin allows to configure the API token which is used to authenticate to Step
- Project selection (multitenancy): because a user can have access to several projects in Step, the EE version allows to select the target project for deploying and running packages
Optional When triggering an execution on Step, an error summary is collected at the end of the execution in case of failure. To read error reports related to enterprise specific features an additional dependency reserved to Enterprise customer is required.
<pluginRepositories>
<pluginRepository>
<id>nexus-exense</id>
<url>https://nexus-enterprise.exense.ch/repository/exense/</url>
</pluginRepository>
</pluginRepositories>
<build>
<pluginManagement>
<plugins>
<!-- Make the Step maven plugin available -->
<plugin>
<groupId>ch.exense.step</groupId>
<artifactId>step-maven-plugin</artifactId>
<version>${step.version}</version>
<!-- adding dependencies to reports nodes for enterprise artefacts, only required to read errors that may occur during isolated executions -->
<dependencies>
<dependency>
<groupId>ch.exense.step-enterprise</groupId>
<artifactId>step-maven-plugin-ee-extensions</artifactId>
<version>${step.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
Usage
Detailed descriptions of the goals are provided below.
Execute Automation Packages in Step
The maven goal execute-automation-package
runs (executes) the plans contained in an Automation Package, on a one-off basis, and in an ephemeral context that is destroyed afterward. In other words, the Automation Package and its contents are not made permanently available on the server, but exist only temporarily during the execution.
The Automation Packages can either be:
- built as a part of current maven project
- an artefact deployed on an artefact repository
For this last case, the artifactGroupId, artifactId and artifactVersion must be specified. Remember that your Step instance needs to be configured to access this artefact repository.
Property (xml) | Command Line Alias | Description | Required | Default Value |
---|---|---|---|---|
url | step.url | The URL of running Step server | true | |
stepProjectName | step.step-project-name | The name of the target project in Step (Step Enterprise only) | false | |
authToken | step.auth-token | The authentication token issued by the Step server (Step Enterprise only) | false | |
userId | step-execute-auto-packages.user-id | The user id used for starting the execution | false | user of the authentication token |
artifactGroupId | step-execute-auto-packages.artifact-group-id | For execution from an artefact repository: the group id of the maven artifact | false | ${project.groupId} |
artifactId | step-execute-auto-packages.artifact-id | For execution from an artefact repository: The id of the maven artifact | false | ${project.artifactId} |
artifactVersion | step-execute-auto-packages.artifact-version | For execution from an artefact repository: The version of the maven artifact | false | ${project.version} |
artifactClassifier | step-execute-auto-packages.artifact-classifier | The classifier of the maven artifact (jar, jar-with-dependencies, tests etc) | false | no classifier |
executionParameters | step-execute-auto-packages.execution-parameters | The execution parameters to be set for the execution | false | |
waitForExecution | step-execute-auto-packages.wait-for-exec | If this value is ‘false’, the execution is started asynchronously and the maven lifecyle continues without waiting the execution result. If this value is ’true’, the maven lifecycle is suspended until the execution is finished | false | true |
executionResultTimeoutS | step-execute-auto-packages.exec-result-timeout-s | If the value of waitForExecution is true, this timeout (in seconds) is applied for running execution |
false | 30 |
ensureExecutionSuccess | step-execute-auto-packages.ensure-exec-success | If the value of waitForExecution is true, the plugin will analyze the execution result and stop the maven lifecycle if this results is not successful |
false | true |
includePlans | step-execute-auto-packages.include-plans | Comma-separated list of plans to include in execution | false | all plans |
excludePlans | step-execute-auto-packages.exclude-plans | Comma-separated list of plans to exclude from execution | false | none |
includeCategories | step-execute-auto-packages.include-categories | Comma-separated list of categories to include in execution | false | all categories |
excludeCategories | step-execute-auto-packages.exclude-categories | Comma-separated list of categories to exclude from execution | false | none |
wrapIntoTestSet | step-execute-auto-packages.wrap-into-test-set | When true, wraps all the plans into a TestSet at execution time. All the plans are then executed within a single TestSet instead of executing all the plans individually. | false | false |
numberOfThreads | step-execute-auto-packages.number-of-threads | When wrapIntoTestSet is true, this option can be used to defines the parallelism within the TestSet. | false | 1 |
Example:
<plugin>
<groupId>ch.exense.step</groupId>
<artifactId>step-maven-plugin</artifactId>
<executions>
<execution>
<id>run-automation-package-in-step</id>
<phase>package</phase>
<configuration>
<url>http://localhost:4201</url>
<stepProjectName>Common</stepProjectName>
<authToken>eyJhbGciO.....iJIUzI</authToken>
<executionParameters>
<env>PROD</env>
<PARAM_EXEC>Value</PARAM_EXEC>
<PARAM_EXEC2>Value</PARAM_EXEC2>
</executionParameters>
</configuration>
<goals>
<goal>execute-automation-package</goal>
</goals>
</execution>
</executions>
</plugin>
To call the plugin from the command line you can use the following command:
mvn package step:execute-automation-package "-Dstep.url=https://your.step.server/" "-Dstep.step-project-name=Common" "-Dstep.auth-token=yourtoken"
Please note the call to the package
phase in this command line: it is required because the command step:execute-automation-package
doesn’t build the project.
Deploy Automation Packages to Step
The maven goal deploy-automation-package
deploys an Automation Package on a Step Server. The deployment makes available (and activates) all content contained in the Automation Package, such as keywords, plans, schedules, etc.
Property (xml) | Command Line Alias | Description | Required | Default Value |
---|---|---|---|---|
url | step.url | The URL of running Step server | true | |
stepProjectName | step.step-project-name | The name of the target project in Step | false | |
authToken | step.auth-token | The authentication token issued by Step server | false | |
artifactClassifier | step-deploy-automation-package.artifact-classifier | The classifier of the maven artifact (jar, jar-with-dependencies, tests etc) | false | no classifier |
async | step-deploy-automation-package.async | Updating an existing package while executions based on it are running will be delayed until these executions end. Whith this property set to true, the plugin will not wait in case of delayed updates | false | false |
<plugin>
<groupId>ch.exense.step</groupId>
<artifactId>step-maven-plugin</artifactId>
<executions>
<execution>
<id>deployed-automation-package-in-step</id>
<phase>deploy</phase>
<configuration>
<url>http://localhost:4201</url>
<stepProjectName>Common</stepProjectName>
<authToken>eyJhbGciO.....iJIUzI</authToken>
</configuration>
<goals>
<goal>deploy-automation-package</goal>
</goals>
</execution>
</executions>
</plugin>
To call the plugin from command line you can use the following command from the maven module where you have the deployed artifact with step Automation Package:
mvn deploy step:deploy-automation-package "-Dstep.url=https://your.step.server/" "-Dstep.step-project-name=Common" "-Dstep.auth-token=your_token_in_text_format"
Upload Keywords to Step (deprecated)
This Maven goal deploys a packaged jar containing Step keywords to the configured Step server as a Keyword Package. The plugin determines if the same Keyword Package has already been uploaded to Step earlier and updates it if found, otherwise it creates a new Keyword Package in Step.
You need to use the upload-keywords-package
goal of the step-maven-plugin
.
This goal has the following configuration
Property (xml) | Command Line Alias | Description | Required | Default Value |
---|---|---|---|---|
url | step.url | The URL of a running Step server | true | |
stepProjectName | step.step-project-name | The name of the target project in Step (Enterprise only) | false | |
authToken | step.auth-token | The authentication token issued by the Step server (Enterprise only) | false | |
customPackageAttributes | step-upload-keywords.custom-package-attrs | Custom attributes passed to uploaded package to Step | false | |
trackingAttribute | step-upload-keywords.tracking-attr | The ’tracking’ string used to identify the uniqueness of the uploaded package (if a package with the same tracking attribute already exists in step, this package will be updated) | false | ${project.groupId}.${project.artifactId} |
artifactClassifier | step-upload-keywords.artifact-classifier | The classifier of the maven artifact (jar, jar-with-dependencies, tests etc) | false | no classifier |
libStepResourceSearchCriteria | step-upload-keywords.lib-step-resource-search-criteria | The attributes of Step resource, which should be used as keyword package library file. You can define the following criteria (nested properties) to specify the target resource: id , name , projectId |
false | |
libArtifactGroupId | step-upload-keywords.lib-artifact-group-id | The group id of the keyword package library file (jar file, previously uploaded to the maven repository) | false | |
libArtifactId | step-upload-keywords.lib-artifact-id | The artifact id of the keyword package library file (jar file, previously uploaded to the maven repository) | false | |
libArtifactVersion | step-upload-keywords.lib-artifact-version | The artifact version of keyword package library file (jar file, previously uploaded to the maven repository) | false | |
libArtifactClassifier | step-upload-keywords.lib-artifact-classifier | The artifact classifier of keyword package library file (jar file, previously uploaded to the maven repository) | false | no classifier |
Example:
<plugin>
<groupId>ch.exense.step</groupId>
<artifactId>step-maven-plugin</artifactId>
<executions>
<execution>
<id>upload-package-to-step</id>
<phase>package</phase>
<configuration>
<url>http://localhost:4201</url>
<!-- For EE, configure the target project and authentication key -->
<!--<stepProjectName>Common</stepProjectName>
<authToken>eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJhMjUyYzhhNi1kO...</authToken>-->
<!-- Example of library file configuration -->
<!--
<libStepResourceSearchCriteria>
<id>64d933c88d944d61db7725e0</id>
</libStepResourceSearchCriteria>
-->
</configuration>
<goals>
<goal>upload-keywords-package</goal>
</goals>
</execution>
</executions>
</plugin>
You can use the following command to execute the plugin goal from the module containing package artifact with step keywords:
mvn package step:upload-keywords-package "-Dstep.url=https://your.step.server/"