mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-02-07 13:42:23 +02:00
Merge branch 'master' into CCFenner/notifications
This commit is contained in:
commit
785e4087d8
@ -1,38 +1,21 @@
|
||||
# batsExecuteTests
|
||||
# ${docGenStepName}
|
||||
|
||||
## Description
|
||||
|
||||
This step executes tests using the [Bash Automated Testing System - bats-core](https://github.com/bats-core/bats-core)
|
||||
## ${docGenDescription}
|
||||
|
||||
## Prerequsites
|
||||
|
||||
You need to have a Bats test file. By default you would put this into directory `src/test` within your source code repository.
|
||||
|
||||
## Parameters
|
||||
## ${docGenParameters}
|
||||
|
||||
| parameter | mandatory | default | possible values |
|
||||
|-----------|-----------|---------|-----------------|
|
||||
| script | yes | | |
|
||||
| dockerImage | no | `node:8-stretch` | |
|
||||
| dockerWorkspace | no |`/home/node`| |
|
||||
| envVars | no | `[:]` | |
|
||||
| failOnError | no | `false` | |
|
||||
| gitBranch | no | | |
|
||||
| gitSshKeyCredentialsId | no | | |
|
||||
| outputFormat | no | `junit` | `tap` |
|
||||
| repository | no | `https://github.com/bats-core/bats-core.git` | |
|
||||
| stashContent | no | `['tests']` | |
|
||||
| testPackage | no | `piper-bats` | |
|
||||
| testPath | no | `src/test`| |
|
||||
| testRepository | no | | |
|
||||
## ${docGenConfiguration}
|
||||
|
||||
Details:
|
||||
## Example
|
||||
|
||||
* `outputFormat` defines the format of the test result output. `junit` would be the standard for automated build environments but you could use also the option `tap`.
|
||||
* For the transformation of the test result to xUnit format the node module **tap-xunit** is used. `dockerImage` and `dockerWorkspace` define the Docker image used for the transformation and `testPackage` defines the name of the test package used in the xUnit result file.
|
||||
* `testPath` defines either the directory which contains the test files (`*.bats`) or a single file. You can find further details in the [Bats-core documentation](https://github.com/bats-core/bats-core#usage)
|
||||
* With `failOnError` you can define the behavior, in case tests fail. For example, in case of `outputFormat: 'junit'` you should set it to `false`. Otherwise test results cannot be recorded using the `testsPublishhResults` step afterwards.
|
||||
* You can pass environment variables to the test execution by defining parameter `envVars`.
|
||||
```groovy
|
||||
batsExecuteTests script:this
|
||||
testsPublishResults junit: [pattern: '**/Test-*.xml', archive: true]
|
||||
```
|
||||
|
||||
With `envVars` it is possible to pass either fixed values but also templates using [`commonPipelineEnvironment`](commonPipelineEnvironment.md).
|
||||
|
||||
@ -41,37 +24,10 @@ Details:
|
||||
```yaml
|
||||
batsExecuteTests script: this, envVars = [
|
||||
FIX_VALUE: 'my fixed value',
|
||||
CONTAINER_NAME: '${commonPipelineEnvironment.configuration.steps.executeBatsTests.dockerContainerName}',
|
||||
IMAGE_NAME: '${return commonPipelineEnvironment.getDockerImageNameAndTag()}'
|
||||
CONTAINER_NAME: '\${commonPipelineEnvironment.configuration.steps.executeBatsTests.dockerContainerName}',
|
||||
IMAGE_NAME: '\${return commonPipelineEnvironment.getDockerImageNameAndTag()}'
|
||||
]
|
||||
```
|
||||
|
||||
This means within the test one could refer to environment variables by calling e.g.
|
||||
`run docker run --rm -i --name $CONTAINER_NAME --entrypoint /bin/bash $IMAGE_NAME echo "Test"`
|
||||
|
||||
* Using parameters `testRepository` the tests can be loaded from another reposirory. In case the tests are not located in the master branch the branch can be specified with `gitBranch`. For protected repositories you can also define the access credentials via `gitSshKeyCredentialsId`. **Note: In case of using a protected repository, `testRepository` should include the ssh link to the repository.**
|
||||
* The parameter `repository` defines the version of **bats-core** to be used. By default we use the version from the master branch.
|
||||
|
||||
## Step configuration
|
||||
|
||||
The following parameters can also be specified as step/stage/general parameters using the [global configuration](../configuration.md):
|
||||
|
||||
* dockerImage
|
||||
* dockerWorkspace
|
||||
* envVars
|
||||
* failOnError
|
||||
* gitBranch
|
||||
* gitSshKeyCredentialsId
|
||||
* outputFormat
|
||||
* repository
|
||||
* stashContent
|
||||
* testPackage
|
||||
* testPath
|
||||
* testRepository
|
||||
|
||||
## Example
|
||||
|
||||
```groovy
|
||||
batsExecuteTests script:this
|
||||
testsPublishResults junit: [pattern: '**/Test-*.xml', archive: true]
|
||||
```
|
||||
`run docker run --rm -i --name \$CONTAINER_NAME --entrypoint /bin/bash \$IMAGE_NAME echo "Test"`
|
||||
|
@ -10,176 +10,6 @@ none
|
||||
|
||||
## Method details
|
||||
|
||||
### getArtifactVersion()
|
||||
|
||||
#### Description
|
||||
|
||||
Returns the version of the artifact which is build in the pipeline.
|
||||
|
||||
#### Parameters
|
||||
|
||||
none
|
||||
|
||||
#### Return value
|
||||
|
||||
A `String` containing the version.
|
||||
|
||||
#### Side effects
|
||||
|
||||
none
|
||||
|
||||
#### Exceptions
|
||||
|
||||
none
|
||||
|
||||
#### Example
|
||||
|
||||
```groovy
|
||||
def myVersion = commonPipelineEnvironment.getArtifactVersion()
|
||||
```
|
||||
|
||||
### setArtifactVersion(version)
|
||||
|
||||
#### Description
|
||||
|
||||
Sets the version of the artifact which is build in the pipeline.
|
||||
|
||||
#### Parameters
|
||||
|
||||
none
|
||||
|
||||
#### Return value
|
||||
|
||||
none
|
||||
|
||||
#### Side effects
|
||||
|
||||
none
|
||||
|
||||
#### Exceptions
|
||||
|
||||
none
|
||||
|
||||
#### Example
|
||||
|
||||
```groovy
|
||||
commonPipelineEnvironment.setArtifactVersion('1.2.3')
|
||||
```
|
||||
|
||||
### getConfigProperties()
|
||||
|
||||
#### Description
|
||||
|
||||
Returns the map of project specific configuration properties. No defensive copy is created.
|
||||
Write operations to the map are visible further down in the pipeline.
|
||||
|
||||
#### Parameters
|
||||
|
||||
none
|
||||
|
||||
#### Return value
|
||||
|
||||
A map containing project specific configuration properties.
|
||||
|
||||
#### Side effects
|
||||
|
||||
none
|
||||
|
||||
#### Exceptions
|
||||
|
||||
none
|
||||
|
||||
#### Example
|
||||
|
||||
```groovy
|
||||
commonPipelineEnvironment.getConfigProperties()
|
||||
```
|
||||
|
||||
### setConfigProperties(configuration)
|
||||
|
||||
#### Description
|
||||
|
||||
Sets the map of configuration properties. Any existing map is overwritten.
|
||||
|
||||
#### Parameters
|
||||
|
||||
* `configuration` - A map containing the new configuration
|
||||
|
||||
#### Return value
|
||||
|
||||
none
|
||||
|
||||
#### Side effects
|
||||
|
||||
none
|
||||
|
||||
#### Exceptions
|
||||
|
||||
none
|
||||
|
||||
#### Example
|
||||
|
||||
```groovy
|
||||
commonPipelineEnvironment.setConfigProperties([DEPLOY_HOST: 'deploy-host.com', DEPLOY_ACCOUNT: 'deploy-account'])
|
||||
```
|
||||
|
||||
### getConfigProperty(property)
|
||||
|
||||
#### Description
|
||||
|
||||
Gets a specific value from the configuration property.
|
||||
|
||||
#### Parameters
|
||||
|
||||
* `property` - The key of the property.
|
||||
|
||||
#### Return value
|
||||
|
||||
* The value associated with key `property`. `null` is returned in case the property does not exist.
|
||||
|
||||
#### Side effects
|
||||
|
||||
none
|
||||
|
||||
#### Exceptions
|
||||
|
||||
none
|
||||
|
||||
#### Example
|
||||
|
||||
```groovy
|
||||
commonPipelineEnvironment.getConfigProperty('DEPLOY_HOST')
|
||||
```
|
||||
|
||||
### setConfigProperty(property, value)
|
||||
|
||||
#### Description
|
||||
|
||||
Sets property `property` with value `value`. Any existing property with key `property` is overwritten.
|
||||
|
||||
#### Parameters
|
||||
|
||||
* `property` - The key of the property.
|
||||
* `value` - The value of the property.
|
||||
|
||||
#### Return value
|
||||
|
||||
none
|
||||
|
||||
#### Side effects
|
||||
|
||||
none
|
||||
|
||||
#### Exceptions
|
||||
|
||||
none
|
||||
|
||||
#### Example
|
||||
|
||||
```groovy
|
||||
commonPipelineEnvironment.setConfigProperty('DEPLOY_HOST', 'my-deploy-host.com')
|
||||
```
|
||||
|
||||
### getInfluxCustomData()
|
||||
|
||||
#### Description
|
||||
@ -239,58 +69,6 @@ none
|
||||
def myInfluxDataMap = commonPipelineEnvironment.getInfluxCustomDataMap()
|
||||
```
|
||||
|
||||
### getMtarFileName()
|
||||
|
||||
#### Description
|
||||
|
||||
Returns the path of the mtar archive file.
|
||||
|
||||
#### Parameters
|
||||
|
||||
none
|
||||
|
||||
#### Return value
|
||||
|
||||
The path of the mtar archive file.
|
||||
|
||||
#### Side effects
|
||||
|
||||
none
|
||||
|
||||
#### Exceptions
|
||||
|
||||
none
|
||||
|
||||
#### Example
|
||||
|
||||
```groovy
|
||||
commonPipelineEnvironment.getMtarFileName()
|
||||
```
|
||||
|
||||
### setMtarFileName(name)
|
||||
|
||||
#### Description
|
||||
|
||||
Sets the path of the mtar archive file. Any old value is discarded.
|
||||
|
||||
#### Parameters
|
||||
|
||||
* `mtarFilePath` - The path of the mtar archive file name.
|
||||
|
||||
#### Side effects
|
||||
|
||||
none
|
||||
|
||||
#### Exceptions
|
||||
|
||||
none
|
||||
|
||||
#### Example
|
||||
|
||||
```groovy
|
||||
commonPipelineEnvironment.setMtarFileName('path/to/foo.mtar')
|
||||
```
|
||||
|
||||
### getPipelineMeasurement(measurementName)
|
||||
|
||||
#### Description
|
||||
|
@ -1,20 +1,15 @@
|
||||
# containerExecuteStructureTests
|
||||
# ${docGenStepName}
|
||||
|
||||
## Description
|
||||
|
||||
In this step [Container Structure Tests](https://github.com/GoogleContainerTools/container-structure-test) are executed.
|
||||
|
||||
This testing framework allows you to execute different test types against a Docker container, for example:
|
||||
|
||||
* Command tests (only if a Docker Deamon is available)
|
||||
* File existence tests
|
||||
* File content tests
|
||||
* Metadata test
|
||||
## ${docGenDescription}
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Test configuration is available.
|
||||
|
||||
## ${docGenParameters}
|
||||
|
||||
## ${docGenConfiguration}
|
||||
|
||||
## Example
|
||||
|
||||
```
|
||||
@ -24,59 +19,3 @@ containerExecuteStructureTests(
|
||||
testImage: 'node:latest'
|
||||
)
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| parameter | mandatory | default | possible values |
|
||||
| ----------|-----------|---------|-----------------|
|
||||
|script|yes|||
|
||||
|containerCommand|no|``||
|
||||
|containerShell|no|``||
|
||||
|dockerImage|yes|`ppiper/container-structure-test`||
|
||||
|dockerOptions|no|`-u 0 --entrypoint=''`||
|
||||
|failOnError|no|`true`|`true`, `false`|
|
||||
|pullImage|no||`true`, `false`|
|
||||
|stashContent|no|<ul><li>`tests`</li></ul>||
|
||||
|testConfiguration|no|||
|
||||
|testDriver|no|||
|
||||
|testImage|no|||
|
||||
|testReportFilePath|no|`cst-report.json`||
|
||||
|verbose|no||`true`, `false`|
|
||||
|
||||
Details:
|
||||
|
||||
* `script` defines the global script environment of the Jenkinsfile run. Typically `this` is passed to this parameter. This allows the function to access the [`commonPipelineEnvironment`](commonPipelineEnvironment.md) for storing the measured duration.
|
||||
* `containerCommand`: Only for Kubernetes environments: Command which is executed to keep container alive, defaults to '/usr/bin/tail -f /dev/null'
|
||||
* containerShell: Only for Kubernetes environments: Shell to be used inside container, defaults to '/bin/sh'
|
||||
* dockerImage: Docker image for code execution.
|
||||
* dockerOptions: Options to be passed to Docker image when starting it (only relevant for non-Kubernetes case).
|
||||
* failOnError: Defines the behavior, in case tests fail.
|
||||
* pullImage: Only relevant for testDriver 'docker'.
|
||||
* stashContent: If specific stashes should be considered for the tests, you can pass this via this parameter.
|
||||
* testConfiguration: Container structure test configuration in yml or json format. You can pass a pattern in order to execute multiple tests.
|
||||
* testDriver: Container structure test driver to be used for testing, please see [https://github.com/GoogleContainerTools/container-structure-test](https://github.com/GoogleContainerTools/container-structure-test) for details.
|
||||
* testImage: Image to be tested
|
||||
* testReportFilePath: Path and name of the test report which will be generated
|
||||
* verbose: Print more detailed information into the log.
|
||||
|
||||
## Step configuration
|
||||
|
||||
We recommend to define values of step parameters via [config.yml file](../configuration.md).
|
||||
|
||||
In following sections the configuration is possible:
|
||||
|
||||
| parameter | general | step | stage |
|
||||
| ----------|-----------|---------|-----------------|
|
||||
|script||||
|
||||
|containerCommand||X|X|
|
||||
|containerShell||X|X|
|
||||
|dockerImage||X|X|
|
||||
|dockerOptions||X|X|
|
||||
|failOnError||X|X|
|
||||
|pullImage||X|X|
|
||||
|stashContent||X|X|
|
||||
|testConfiguration||X|X|
|
||||
|testDriver||X|X|
|
||||
|testImage||X|X|
|
||||
|testReportFilePath||X|X|
|
||||
|verbose|X|X|X|
|
||||
|
@ -1,39 +1,17 @@
|
||||
# gaugeExecuteTests
|
||||
# ${docGenStepName}
|
||||
|
||||
## Description
|
||||
|
||||
In this step Gauge ([getgauge.io](http:getgauge.io)) acceptance tests are executed.
|
||||
Using Gauge it will be possible to have a three-tier test layout:
|
||||
|
||||
* Acceptance Criteria
|
||||
* Test implemenation layer
|
||||
* Application driver layer
|
||||
|
||||
This layout is propagated by Jez Humble and Dave Farley in their book "Continuous Delivery" as a way to create maintainable acceptance test suites (see "Continuous Delivery", p. 190ff).
|
||||
|
||||
Using Gauge it is possible to write test specifications in [Markdown syntax](http://daringfireball.net/projects/markdown/syntax) and therefore allow e.g. product owners to write the relevant acceptance test specifications. At the same time it allows the developer to implement the steps described in the specification in her development environment.
|
||||
|
||||
You can use the [sample projects](https://github.com/getgauge/gauge-mvn-archetypes) of Gauge.
|
||||
|
||||
!!! note "Make sure to run against a Selenium Hub configuration"
|
||||
In the test example of _gauge-archetype-selenium_ please make sure to allow it to run against a Selenium hub:
|
||||
|
||||
Please extend DriverFactory.java for example in following way:
|
||||
|
||||
``` java
|
||||
String hubUrl = System.getenv("HUB_URL");
|
||||
//when running on a Docker deamon (and not using Kubernetes plugin), Docker images will be linked
|
||||
//in this case hubUrl will be http://selenium:4444/wd/hub due to the linking of the containers
|
||||
hubUrl = (hubUrl == null) ? "http://localhost:4444/wd/hub" : hubUrl;
|
||||
Capabilities chromeCapabilities = DesiredCapabilities.chrome();
|
||||
System.out.println("Running on Selenium Hub: " + hubUrl);
|
||||
return new RemoteWebDriver(new URL(hubUrl), chromeCapabilities);
|
||||
```
|
||||
## ${docGenDescription}
|
||||
|
||||
## Prerequsites
|
||||
|
||||
none
|
||||
|
||||
## ${docGenParameters}
|
||||
|
||||
## ${docGenConfiguration}
|
||||
|
||||
We recommend to define values of step parameters via [config.yml file](../configuration.md).
|
||||
|
||||
## Example
|
||||
|
||||
Pipeline step:
|
||||
@ -41,63 +19,3 @@ Pipeline step:
|
||||
```groovy
|
||||
gaugeExecuteTests script: this, testServerUrl: 'http://test.url'
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| parameter | mandatory | default | possible values |
|
||||
| ----------|-----------|---------|-----------------|
|
||||
|script|yes|||
|
||||
|buildTool|no|`maven`||
|
||||
|dockerEnvVars|no|`[HUB:TRUE, HUB_URL:http://localhost:4444/wd/hub]`||
|
||||
|dockerImage|no|buildTool=`maven`: `maven:3.5-jdk-8`<br />buildTool=`npm`: `node:8-stretch`<br />||
|
||||
|dockerName|no|buildTool=`maven`: `maven`<br />buildTool=`npm`: `npm`<br />||
|
||||
|dockerWorkspace|no|buildTool=`maven`: <br />buildTool=`npm`: `/home/node`<br />||
|
||||
|failOnError|no|`false`||
|
||||
|gitBranch|no|||
|
||||
|gitSshKeyCredentialsId|no|``||
|
||||
|installCommand|no|`curl -SsL https://downloads.gauge.org/stable | sh -s -- --location=$HOME/bin/gauge`||
|
||||
|languageRunner|no|buildTool=`maven`: `java`<br />buildTool=`npm`: `js`<br />||
|
||||
|runCommand|no|buildTool=`maven`: `mvn test-compile gauge:execute`<br />buildTool=`npm`: `gauge run`<br />||
|
||||
|stashContent|no|<ul><li>`buildDescriptor`</li><li>`tests`</li></ul>||
|
||||
|testOptions|no|buildTool=`maven`: `-DspecsDir=specs`<br />buildTool=`npm`: `specs`<br />||
|
||||
|testRepository|no|||
|
||||
|testServerUrl|no|||
|
||||
|
||||
Details:
|
||||
|
||||
* `script` defines the global script environment of the Jenkinsfile run. Typically `this` is passed to this parameter. This allows the function to access the [`commonPipelineEnvironment`](commonPipelineEnvironment.md) for storing the measured duration.
|
||||
* `buildTool` defines the build tool to be used for the test execution.
|
||||
* `dockerEnvVars`, see step [dockerExecute](dockerExecute.md)
|
||||
* `dockerImage`, see step [dockerExecute](dockerExecute.md)
|
||||
* `dockerName`, see step [dockerExecute](dockerExecute.md)
|
||||
* `dockerWorkspace`, see step [dockerExecute](dockerExecute.md)
|
||||
* With `failOnError` you can define the behavior, in case tests fail. When this is set to `true` test results cannot be recorded using the `publishTestResults` step afterwards.
|
||||
* `installCommand` defines the command for installing Gauge. In case the `dockerImage` already contains Gauge it can be set to empty: ``.
|
||||
* `languageRunner` defines the Gauge language runner to be used.
|
||||
* `runCommand` defines the command which is used for executing Gauge.
|
||||
* If specific stashes should be considered for the tests, you can pass this via parameter `stashContent`
|
||||
* `testOptions` allows to set specific options for the Gauge execution. Details can be found for example [in the Gauge Maven plugin documentation](https://github.com/getgauge/gauge-maven-plugin#executing-specs)
|
||||
* In case the test implementation is stored in a different repository than the code itself, you can define the repository containing the tests using parameter `testRepository` and if required `gitBranch` (for a different branch than master) and `gitSshKeyCredentialsId` (for protected repositories). For protected repositories the `testRepository` needs to contain the ssh git url.
|
||||
* `testServerUrl` is passed as environment variable `TARGET_SERVER_URL` to the test execution. Tests running against the system should read the host information from this environment variable in order to be infrastructure agnostic.
|
||||
|
||||
## Step configuration
|
||||
|
||||
We recommend to define values of step parameters via [config.yml file](../configuration.md).
|
||||
|
||||
In following sections the configuration is possible:
|
||||
|
||||
| parameter | general | step | stage |
|
||||
| ----------|-----------|---------|-----------------|
|
||||
|script||||
|
||||
|buildTool||X|X|
|
||||
|dockerEnvVars||X|X|
|
||||
|dockerImage||X|X|
|
||||
|dockerName||X|X|
|
||||
|dockerWorkspace||X|X|
|
||||
|failOnError||X|X|
|
||||
|gitBranch||X|X|
|
||||
|gitSshKeyCredentialsId||X|X|
|
||||
|stashContent||X|X|
|
||||
|testOptions||X|X|
|
||||
|testRepository||X|X|
|
||||
|testServerUrl||X|X|
|
||||
|
@ -1,25 +1,15 @@
|
||||
# pipelineRestartSteps
|
||||
# ${docGenStepName}
|
||||
|
||||
## Description
|
||||
|
||||
Support of restarting failed stages or steps in a pipeline is limited in Jenkins.
|
||||
|
||||
This has been documented in the [Jenkins Jira issue JENKINS-33846](https://issues.jenkins-ci.org/browse/JENKINS-33846).
|
||||
|
||||
For declarative pipelines there is a solution available which partially addresses this topic:
|
||||
https://jenkins.io/doc/book/pipeline/running-pipelines/#restart-from-a-stage.
|
||||
|
||||
Nonetheless, still features are missing, so it can't be used in all cases.
|
||||
The more complex Piper pipelines which share a state via [`commonPipelineEnvironment`](commonPipelineEnvironment.md) will for example not work with the standard _restart-from-stage_.
|
||||
|
||||
The step `pipelineRestartSteps` aims to address this gap and allows individual parts of a pipeline (e.g. a failed deployment) to be restarted.
|
||||
|
||||
This is done in a way that the pipeline waits for user input to restart the pipeline in case of a failure. In case this user input is not provided the pipeline stops after a timeout which can be configured.
|
||||
## ${docGenDescription}
|
||||
|
||||
## Prerequisites
|
||||
|
||||
none
|
||||
|
||||
## ${docGenParameters}
|
||||
|
||||
## ${docGenConfiguration}
|
||||
|
||||
## Example
|
||||
|
||||
Usage of pipeline step:
|
||||
@ -37,32 +27,6 @@ pipelineRestartSteps (script: this) {
|
||||
|
||||
In case you cannot use `node` inside this step, please choose the parameter `timeoutInSeconds` carefully!
|
||||
|
||||
## Parameters
|
||||
|
||||
| parameter | mandatory | default | possible values |
|
||||
| ----------|-----------|---------|-----------------|
|
||||
|script|yes|||
|
||||
|sendMail|no|`true`||
|
||||
|timeoutInSeconds|no|`900`||
|
||||
|
||||
### Details
|
||||
|
||||
* `script` defines the global script environment of the Jenkinsfile run. Typically `this` is passed to this parameter. This allows the function to access the [`commonPipelineEnvironment`](commonPipelineEnvironment.md) for storing the measured duration.
|
||||
* If `sendMail: true` the step `mailSendNotification` will be triggered in case of an error
|
||||
* `timeoutInSeconds` defines the time period where the job waits for input. Default is 15 minutes. Once this time is passed the job enters state FAILED.
|
||||
|
||||
## Step configuration
|
||||
|
||||
We recommend to define values of step parameters via [config.yml file](../configuration.md).
|
||||
|
||||
In following sections the configuration is possible:
|
||||
|
||||
| parameter | general | step | stage |
|
||||
| ----------|-----------|---------|-----------------|
|
||||
|script||||
|
||||
|sendMail|X|X|X|
|
||||
|timeoutInSeconds|X|X|X|
|
||||
|
||||
## Side effects
|
||||
|
||||
none
|
||||
|
@ -1,17 +1,10 @@
|
||||
# prepareDefaultValues
|
||||
# ${docGenStepName}
|
||||
|
||||
## Description
|
||||
## ${docGenDescription}
|
||||
|
||||
Loads the pipeline library default values from the file `resources/default_pipeline_environment.yml`.
|
||||
Afterwards the values can be loaded by the method: `ConfigurationLoader.defaultStepConfiguration`
|
||||
## ${docGenParameters}
|
||||
|
||||
## Parameters
|
||||
|
||||
None
|
||||
|
||||
## Step configuration
|
||||
|
||||
None
|
||||
## ${docGenConfiguration}
|
||||
|
||||
## Exceptions
|
||||
|
||||
|
@ -1,30 +1,14 @@
|
||||
# setupCommonPipelineEnvironment
|
||||
# ${docGenStepName}
|
||||
|
||||
## Description
|
||||
|
||||
Initializes the [`commonPipelineEnvironment`](commonPipelineEnvironment.md), which is used throughout the complete pipeline.
|
||||
|
||||
!!! tip
|
||||
This step needs to run at the beginning of a pipeline right after the SCM checkout.
|
||||
Then subsequent pipeline steps consume the information from `commonPipelineEnvironment`; it does not need to be passed to pipeline steps explicitly.
|
||||
## ${docGenDescription}
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* A **configuration file** with properties (default location: `.pipeline/config.properties`). The property values are used as default values in many pipeline steps.
|
||||
* A **configuration file** with properties. The property values are used as default values in many pipeline steps.
|
||||
|
||||
## Parameters
|
||||
## ${docGenParameters}
|
||||
|
||||
| parameter | mandatory | default | possible values |
|
||||
| ------------ |-----------|-------------------------------|-----------------|
|
||||
| `script` | yes | - | |
|
||||
| `configFile` | no | `.pipeline/config.properties` | |
|
||||
|
||||
* `script` - The reference to the pipeline script (Jenkinsfile). Normally `this` needs to be provided.
|
||||
* `configFile` - Property file defining project specific settings.
|
||||
|
||||
## Step configuration
|
||||
|
||||
none
|
||||
## ${docGenConfiguration}
|
||||
|
||||
## Side effects
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
# testsPublishResults
|
||||
# ${docGenStepName}
|
||||
|
||||
## Description
|
||||
|
||||
This step can publish test results from various sources.
|
||||
## ${docGenDescription}
|
||||
|
||||
## Prerequsites
|
||||
|
||||
@ -28,29 +26,7 @@ testsPublishResults(
|
||||
)
|
||||
```
|
||||
|
||||
Available parameters:
|
||||
|
||||
| parameter | mandatory | default | possible values |
|
||||
| ----------|-----------|---------|-----------------|
|
||||
| script | yes | | |
|
||||
| `failOnError` | no | `false` | `true`, `false` |
|
||||
| junit | no | `false` | true, false |
|
||||
| jacoco | no | `false` | true, false |
|
||||
| cobertura | no | `false` | true, false |
|
||||
| jmeter | no | `false` | true, false |
|
||||
|
||||
* `script` - The common script environment of the Jenkinsfile running.
|
||||
Typically the reference to the script calling the pipeline step is provided
|
||||
with the `this` parameter, as in `script: this`.
|
||||
This allows the function to access the [`commonPipelineEnvironment`](commonPipelineEnvironment.md)
|
||||
for retrieving, for example, configuration parameters.
|
||||
* `failOnError` - If `failOnError` it set to `true` the step will fail the build if JUnit detected any failing tests.
|
||||
* `junit` - Publishes test results files in JUnit format with the [JUnit Plugin](https://plugins.jenkins.io/junit).
|
||||
* `jacoco` - Publishes code coverage with the [JaCoCo plugin](https://plugins.jenkins.io/jacoco) .
|
||||
* `cobertura` - Publishes code coverage with the [Cobertura plugin](https://plugins.jenkins.io/cobertura).
|
||||
* `jmeter` - Publishes performance test results with the [Performance plugin](https://plugins.jenkins.io/performance).
|
||||
|
||||
Each of the parameters `junit`, `jacoco`, `cobertura` and `jmeter` can be set to `true` or `false` but also to a map of parameters to hand in different settings for the tools.
|
||||
## ${docGenParameters}
|
||||
|
||||
### junit
|
||||
|
||||
@ -101,14 +77,7 @@ Each of the parameters `junit`, `jacoco`, `cobertura` and `jmeter` can be set to
|
||||
| archive | no | `false` | true, false |
|
||||
| allowEmptyResults | no | `true` | true, false |
|
||||
|
||||
## Step configuration
|
||||
|
||||
Following parameters can also be specified as step parameters using the global configuration file:
|
||||
|
||||
* `junit`
|
||||
* `jacoco`
|
||||
* `cobertura`
|
||||
* `jmeter`
|
||||
## ${docGenConfiguration}
|
||||
|
||||
## Side effects
|
||||
|
||||
|
@ -348,6 +348,10 @@ steps:
|
||||
- 'opensourceConfiguration'
|
||||
verbose: false
|
||||
timeout: 0
|
||||
pipelineExecute:
|
||||
branch: 'master'
|
||||
path: 'Jenkinsfile'
|
||||
credentialsId: ''
|
||||
pipelineRestartSteps:
|
||||
sendMail: true
|
||||
timeoutInSeconds: 900
|
||||
|
@ -7,19 +7,6 @@ import groovy.text.SimpleTemplateEngine
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.security.MessageDigest
|
||||
|
||||
@NonCPS
|
||||
def getMandatoryParameter(Map map, paramName, defaultValue = null) {
|
||||
|
||||
def paramValue = map[paramName]
|
||||
|
||||
if (paramValue == null)
|
||||
paramValue = defaultValue
|
||||
|
||||
if (paramValue == null)
|
||||
throw new Exception("ERROR - NO VALUE AVAILABLE FOR ${paramName}")
|
||||
return paramValue
|
||||
|
||||
}
|
||||
|
||||
def stash(name, include = '**/*.*', exclude = '', useDefaultExcludes = true) {
|
||||
echo "Stash content: ${name} (include: ${include}, exclude: ${exclude}, useDefaultExcludes: ${useDefaultExcludes})"
|
||||
|
@ -11,6 +11,7 @@ import util.JenkinsReadYamlRule
|
||||
import util.JenkinsStepRule
|
||||
|
||||
class PipelineExecuteTest extends BasePiperTest {
|
||||
|
||||
private ExpectedException thrown = new ExpectedException().none()
|
||||
private JenkinsStepRule stepRule = new JenkinsStepRule(this)
|
||||
|
||||
@ -27,9 +28,6 @@ class PipelineExecuteTest extends BasePiperTest {
|
||||
|
||||
@Before
|
||||
void init() {
|
||||
pipelinePath = null
|
||||
checkoutParameters.clear()
|
||||
load = null
|
||||
|
||||
helper.registerAllowedMethod('deleteDir', [], null)
|
||||
helper.registerAllowedMethod('checkout', [Map], { m ->
|
||||
@ -44,17 +42,19 @@ class PipelineExecuteTest extends BasePiperTest {
|
||||
|
||||
@Test
|
||||
void straightForwardTest() {
|
||||
|
||||
stepRule.step.pipelineExecute(repoUrl: "https://test.com/myRepo.git")
|
||||
|
||||
assert load == "Jenkinsfile"
|
||||
assert checkoutParameters.branch == 'master'
|
||||
assert checkoutParameters.repoUrl == "https://test.com/myRepo.git"
|
||||
assert checkoutParameters.credentialsId == ''
|
||||
assert checkoutParameters.path == 'Jenkinsfile'
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void parameterizeTest() {
|
||||
|
||||
stepRule.step.pipelineExecute(repoUrl: "https://test.com/anotherRepo.git",
|
||||
branch: 'feature',
|
||||
path: 'path/to/Jenkinsfile',
|
||||
@ -65,11 +65,11 @@ class PipelineExecuteTest extends BasePiperTest {
|
||||
assert checkoutParameters.repoUrl == "https://test.com/anotherRepo.git"
|
||||
assert checkoutParameters.credentialsId == 'abcd1234'
|
||||
assert checkoutParameters.path == 'path/to/Jenkinsfile'
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void noRepoUrlTest() {
|
||||
|
||||
thrown.expect(Exception)
|
||||
thrown.expectMessage("ERROR - NO VALUE AVAILABLE FOR repoUrl")
|
||||
|
||||
|
@ -41,29 +41,6 @@ class UtilsTest extends BasePiperTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void noValueGetMandatoryParameterTest() {
|
||||
|
||||
thrown.expect(Exception)
|
||||
thrown.expectMessage("ERROR - NO VALUE AVAILABLE FOR test")
|
||||
|
||||
utils.getMandatoryParameter(parameters, 'test', null)
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultValueGetMandatoryParameterTest() {
|
||||
|
||||
assert utils.getMandatoryParameter(parameters, 'test', 'default') == 'default'
|
||||
}
|
||||
|
||||
@Test
|
||||
void valueGetmandatoryParameterTest() {
|
||||
|
||||
parameters.put('test', 'value')
|
||||
|
||||
assert utils.getMandatoryParameter(parameters, 'test', null) == 'value'
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenerateSHA1() {
|
||||
def result = utils.generateSha1('ContinuousDelivery')
|
||||
|
@ -1,5 +1,6 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.GenerateDocumentation
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.GitUtils
|
||||
import com.sap.piper.Utils
|
||||
@ -11,22 +12,44 @@ import groovy.transform.Field
|
||||
@Field Set GENERAL_CONFIG_KEYS = STEP_CONFIG_KEYS
|
||||
|
||||
@Field Set STEP_CONFIG_KEYS = [
|
||||
/** @see dockerExecute */
|
||||
'dockerImage',
|
||||
/** @see dockerExecute */
|
||||
'dockerWorkspace',
|
||||
'envVars',
|
||||
'failOnError',
|
||||
'gitBranch',
|
||||
'gitSshKeyCredentialsId',
|
||||
'outputFormat',
|
||||
'repository',
|
||||
/** @see dockerExecute */
|
||||
'stashContent',
|
||||
/** Defines the environment variables to pass to the test execution.*/
|
||||
'envVars',
|
||||
/** Defines the behavior, in case tests fail. For example, in case of `outputFormat: 'junit'` you should set it to `false`. Otherwise test results cannot be recorded using the `testsPublishhResults` step afterwards.*/
|
||||
'failOnError',
|
||||
/**
|
||||
* Defines the format of the test result output. `junit` would be the standard for automated build environments but you could use also the option `tap`.
|
||||
* @possibleValues `tap`
|
||||
*/
|
||||
'outputFormat',
|
||||
/**
|
||||
* Defines the version of **bats-core** to be used. By default we use the version from the master branch.
|
||||
*/
|
||||
'repository',
|
||||
/** For the transformation of the test result to xUnit format the node module **tap-xunit** is used. This parameter defines the name of the test package used in the xUnit result file.*/
|
||||
'testPackage',
|
||||
/** Defines either the directory which contains the test files (`*.bats`) or a single file. You can find further details in the [Bats-core documentation](https://github.com/bats-core/bats-core#usage).*/
|
||||
'testPath',
|
||||
'testRepository'
|
||||
/** Allows to load tests from another repository.*/
|
||||
'testRepository',
|
||||
/** Defines the branch where the tests are located, in case the tests are not located in the master branch.*/
|
||||
'gitBranch',
|
||||
/**
|
||||
* Defines the access credentials for protected repositories.
|
||||
* Note: In case of using a protected repository, `testRepository` should include the ssh link to the repository.
|
||||
*/
|
||||
'gitSshKeyCredentialsId'
|
||||
]
|
||||
|
||||
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
|
||||
|
||||
/** This step executes tests using the [Bash Automated Testing System - bats-core](https://github.com/bats-core/bats-core)*/
|
||||
@GenerateDocumentation
|
||||
void call(Map parameters = [:]) {
|
||||
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.GenerateDocumentation
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.Utils
|
||||
import groovy.transform.Field
|
||||
@ -12,40 +13,39 @@ import groovy.transform.Field
|
||||
* @possibleValues `true`, `false`
|
||||
*/
|
||||
'verbose'
|
||||
|
||||
]
|
||||
|
||||
@Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus([
|
||||
/**
|
||||
* Only for Kubernetes environments: Command which is executed to keep container alive, defaults to '/usr/bin/tail -f /dev/null'
|
||||
* @see dockerExecute
|
||||
*/
|
||||
'containerCommand',
|
||||
/**
|
||||
* Only for Kubernetes environments: Shell to be used inside container, defaults to '/bin/sh'
|
||||
* @see dockerExecute
|
||||
*/
|
||||
'containerShell',
|
||||
/**
|
||||
* Docker image for code execution.
|
||||
*/
|
||||
* @see dockerExecute
|
||||
*/
|
||||
'dockerImage',
|
||||
/**
|
||||
* Options to be passed to Docker image when starting it (only relevant for non-Kubernetes case).
|
||||
* @see dockerExecute
|
||||
*/
|
||||
'dockerOptions',
|
||||
/**
|
||||
* Defines the behavior, in case tests fail.
|
||||
* @possibleValues `true`, `false`
|
||||
*/
|
||||
* @see dockerExecute
|
||||
*/
|
||||
'stashContent',
|
||||
/**
|
||||
* Defines the behavior, in case tests fail.
|
||||
* @possibleValues `true`, `false`
|
||||
*/
|
||||
'failOnError',
|
||||
/**
|
||||
* Only relevant for testDriver 'docker'.
|
||||
* @possibleValues `true`, `false`
|
||||
*/
|
||||
'pullImage',
|
||||
/**
|
||||
* If specific stashes should be considered for the tests, you can pass this via this parameter.
|
||||
*/
|
||||
'stashContent',
|
||||
/**
|
||||
* Container structure test configuration in yml or json format. You can pass a pattern in order to execute multiple tests.
|
||||
*/
|
||||
@ -55,8 +55,8 @@ import groovy.transform.Field
|
||||
*/
|
||||
'testDriver',
|
||||
/**
|
||||
* Image to be tested
|
||||
*/
|
||||
* Image to be tested
|
||||
*/
|
||||
'testImage',
|
||||
/**
|
||||
* Path and name of the test report which will be generated
|
||||
@ -66,6 +66,17 @@ import groovy.transform.Field
|
||||
|
||||
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
|
||||
|
||||
/**
|
||||
* In this step [Container Structure Tests](https://github.com/GoogleContainerTools/container-structure-test) are executed.
|
||||
*
|
||||
* This testing framework allows you to execute different test types against a Docker container, for example:
|
||||
*
|
||||
* * Command tests (only if a Docker Deamon is available)
|
||||
* * File existence tests
|
||||
* * File content tests
|
||||
* * Metadata test
|
||||
*/
|
||||
@GenerateDocumentation
|
||||
void call(Map parameters = [:]) {
|
||||
handlePipelineStepErrors(stepName: STEP_NAME, stepParameters: parameters) {
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.GenerateDocumentation
|
||||
import com.sap.piper.Utils
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.GitUtils
|
||||
@ -7,25 +8,79 @@ import groovy.text.SimpleTemplateEngine
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
|
||||
@Field Set GENERAL_CONFIG_KEYS = []
|
||||
|
||||
@Field Set STEP_CONFIG_KEYS = [
|
||||
/** Defines the build tool to be used for the test execution.*/
|
||||
'buildTool',
|
||||
/** @see dockerExecute*/
|
||||
'dockerEnvVars',
|
||||
/** @see dockerExecute*/
|
||||
'dockerImage',
|
||||
/** @see dockerExecute*/
|
||||
'dockerName',
|
||||
/** @see dockerExecute*/
|
||||
'dockerWorkspace',
|
||||
/**
|
||||
* Defines the behavior in case tests fail. When this is set to `true` test results cannot be recorded using the `publishTestResults` step afterwards.
|
||||
* @possibleValues true, false
|
||||
*/
|
||||
'failOnError',
|
||||
'gitBranch',
|
||||
'gitSshKeyCredentialsId',
|
||||
/** Defines the command for installing Gauge. In case the `dockerImage` already contains Gauge it can be set to empty: ``.*/
|
||||
'installCommand',
|
||||
/** Defines the Gauge language runner to be used.*/
|
||||
'languageRunner',
|
||||
/** Defines the command which is used for executing Gauge.*/
|
||||
'runCommand',
|
||||
/** Defines if specific stashes should be considered for the tests.*/
|
||||
'stashContent',
|
||||
/** Allows to set specific options for the Gauge execution. Details can be found for example [in the Gauge Maven plugin documentation](https://github.com/getgauge/gauge-maven-plugin#executing-specs)*/
|
||||
'testOptions',
|
||||
/** Defines the repository containing the tests, in case the test implementation is stored in a different repository than the code itself.*/
|
||||
'testRepository',
|
||||
/** Defines the branch containing the tests, in case the test implementation is stored in a different repository and a different branch than master.*/
|
||||
'gitBranch',
|
||||
/**
|
||||
* Defines the credentials for the repository containing the tests, in case the test implementation is stored in a different and protected repository than the code itself.
|
||||
* For protected repositories the `testRepository` needs to contain the ssh git url.
|
||||
*/
|
||||
'gitSshKeyCredentialsId',
|
||||
/** It is passed as environment variable `TARGET_SERVER_URL` to the test execution. Tests running against the system should read the host information from this environment variable in order to be infrastructure agnostic.*/
|
||||
'testServerUrl'
|
||||
]
|
||||
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
|
||||
|
||||
/**
|
||||
* In this step Gauge ([getgauge.io](http:getgauge.io)) acceptance tests are executed.
|
||||
* Using Gauge it will be possible to have a three-tier test layout:
|
||||
*
|
||||
* * Acceptance Criteria
|
||||
* * Test implemenation layer
|
||||
* * Application driver layer
|
||||
*
|
||||
* This layout is propagated by Jez Humble and Dave Farley in their book "Continuous Delivery" as a way to create maintainable acceptance test suites (see "Continuous Delivery", p. 190ff).
|
||||
*
|
||||
* Using Gauge it is possible to write test specifications in [Markdown syntax](http://daringfireball.net/projects/markdown/syntax) and therefore allow e.g. product owners to write the relevant acceptance test specifications. At the same time it allows the developer to implement the steps described in the specification in her development environment.
|
||||
*
|
||||
* You can use the [sample projects](https://github.com/getgauge/gauge-mvn-archetypes) of Gauge.
|
||||
*
|
||||
* !!! note "Make sure to run against a Selenium Hub configuration"
|
||||
* In the test example of _gauge-archetype-selenium_ please make sure to allow it to run against a Selenium hub:
|
||||
*
|
||||
* Please extend DriverFactory.java for example in following way:
|
||||
*
|
||||
* ``` java
|
||||
* String hubUrl = System.getenv("HUB_URL");
|
||||
* //when running on a Docker deamon (and not using Kubernetes plugin), Docker images will be linked
|
||||
* //in this case hubUrl will be http://selenium:4444/wd/hub due to the linking of the containers
|
||||
* hubUrl = (hubUrl == null) ? "http://localhost:4444/wd/hub" : hubUrl;
|
||||
* Capabilities chromeCapabilities = DesiredCapabilities.chrome();
|
||||
* System.out.println("Running on Selenium Hub: " + hubUrl);
|
||||
* return new RemoteWebDriver(new URL(hubUrl), chromeCapabilities);
|
||||
* ```
|
||||
*/
|
||||
@GenerateDocumentation
|
||||
void call(Map parameters = [:]) {
|
||||
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
||||
def script = checkScript(this, parameters) ?: this
|
||||
|
@ -1,5 +1,5 @@
|
||||
import com.sap.piper.GenerateDocumentation
|
||||
import com.sap.piper.Utils
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
|
||||
import groovy.transform.Field
|
||||
|
||||
@ -17,7 +17,11 @@ import groovy.transform.Field
|
||||
'branch',
|
||||
/** The path to the Jenkinsfile, inside the repository, to be loaded.*/
|
||||
'path',
|
||||
/** The Jenkins credentials containing user and password needed to access a private git repository.*/
|
||||
/**
|
||||
* The Jenkins credentials containing user and password needed to access a private git repository.
|
||||
* In case access to the repository containing the pipeline script is restricted the credentialsId of the credentials used for
|
||||
* accessing the repository needs to be provided. The corresponding credentials needs to be configured in Jenkins accordingly.
|
||||
*/
|
||||
'credentialsId'
|
||||
]
|
||||
|
||||
@ -34,38 +38,34 @@ void call(Map parameters = [:]) {
|
||||
|
||||
node() {
|
||||
|
||||
def path
|
||||
Map config
|
||||
|
||||
handlePipelineStepErrors (stepName: 'pipelineExecute', stepParameters: parameters, failOnError: true) {
|
||||
|
||||
def utils = new Utils()
|
||||
ConfigurationHelper configHelper = ConfigurationHelper.newInstance(this)
|
||||
.loadStepDefaults()
|
||||
.mixin(parameters, PARAMETER_KEYS)
|
||||
.withMandatoryProperty('repoUrl')
|
||||
.withMandatoryProperty('branch')
|
||||
.withMandatoryProperty('path')
|
||||
.withMandatoryProperty('credentialsId')
|
||||
|
||||
// The coordinates of the pipeline script
|
||||
def repo = utils.getMandatoryParameter(parameters, 'repoUrl', null)
|
||||
def branch = utils.getMandatoryParameter(parameters, 'branch', 'master')
|
||||
|
||||
path = utils.getMandatoryParameter(parameters, 'path', 'Jenkinsfile')
|
||||
|
||||
// In case access to the repository containing the pipeline
|
||||
// script is restricted the credentialsId of the credentials used for
|
||||
// accessing the repository needs to be provided below. The corresponding
|
||||
// credentials needs to be configured in Jenkins accordingly.
|
||||
def credentialsId = utils.getMandatoryParameter(parameters, 'credentialsId', '')
|
||||
config = configHelper.use()
|
||||
|
||||
deleteDir()
|
||||
|
||||
checkout([$class: 'GitSCM', branches: [[name: branch]],
|
||||
doGenerateSubmoduleConfigurations: false,
|
||||
extensions: [[$class: 'SparseCheckoutPaths',
|
||||
sparseCheckoutPaths: [[path: path]]
|
||||
checkout([$class: 'GitSCM', branches: [[name: config.branch]],
|
||||
doGenerateSubmoduleConfigurations: false,
|
||||
extensions: [[$class: 'SparseCheckoutPaths',
|
||||
sparseCheckoutPaths: [[path: config.path]]
|
||||
]],
|
||||
submoduleCfg: [],
|
||||
userRemoteConfigs: [[credentialsId: credentialsId,
|
||||
url: repo
|
||||
submoduleCfg: [],
|
||||
userRemoteConfigs: [[credentialsId: config.credentialsId,
|
||||
url: config.repoUrl
|
||||
]]
|
||||
])
|
||||
|
||||
}
|
||||
load path
|
||||
load config.path
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,43 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.GenerateDocumentation
|
||||
import com.sap.piper.JenkinsUtils
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
|
||||
@Field Set GENERAL_CONFIG_KEYS = []
|
||||
|
||||
@Field Set STEP_CONFIG_KEYS = [
|
||||
/**
|
||||
* If it is set to true` the step `mailSendNotification` will be triggered in case of an error.
|
||||
*/
|
||||
'sendMail',
|
||||
/**
|
||||
* Defines the time period where the job waits for input. Default is 15 minutes. Once this time is passed the job enters state FAILED.
|
||||
*/
|
||||
'timeoutInSeconds'
|
||||
]
|
||||
|
||||
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
|
||||
|
||||
/**
|
||||
* Support of restarting failed stages or steps in a pipeline is limited in Jenkins.
|
||||
*
|
||||
* This has been documented in the [Jenkins Jira issue JENKINS-33846](https://issues.jenkins-ci.org/browse/JENKINS-33846).
|
||||
*
|
||||
* For declarative pipelines there is a solution available which partially addresses this topic:
|
||||
* https://jenkins.io/doc/book/pipeline/running-pipelines/#restart-from-a-stage.
|
||||
*
|
||||
* Nonetheless, still features are missing, so it can't be used in all cases.
|
||||
* The more complex Piper pipelines which share a state via [`commonPipelineEnvironment`](commonPipelineEnvironment.md) will for example not work with the standard _restart-from-stage_.
|
||||
*
|
||||
* The step `pipelineRestartSteps` aims to address this gap and allows individual parts of a pipeline (e.g. a failed deployment) to be restarted.
|
||||
*
|
||||
* This is done in a way that the pipeline waits for user input to restart the pipeline in case of a failure. In case this user input is not provided the pipeline stops after a timeout which can be configured.
|
||||
*/
|
||||
@GenerateDocumentation
|
||||
void call(Map parameters = [:], body) {
|
||||
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters, failOnError: true) {
|
||||
def script = checkScript(this, parameters) ?: this
|
||||
|
@ -1,3 +1,4 @@
|
||||
import com.sap.piper.GenerateDocumentation
|
||||
import com.sap.piper.DefaultValueCache
|
||||
import com.sap.piper.MapUtils
|
||||
|
||||
@ -5,6 +6,15 @@ import groovy.transform.Field
|
||||
|
||||
@Field STEP_NAME = getClass().getName()
|
||||
|
||||
@Field Set GENERAL_CONFIG_KEYS = []
|
||||
@Field Set STEP_CONFIG_KEYS = []
|
||||
@Field Set PARAMETER_KEYS = []
|
||||
|
||||
/**
|
||||
* Loads the pipeline library default values from the file `resources/default_pipeline_environment.yml`.
|
||||
* Afterwards the values can be loaded by the method: `ConfigurationLoader.defaultStepConfiguration`
|
||||
*/
|
||||
@GenerateDocumentation
|
||||
void call(Map parameters = [:]) {
|
||||
if(!DefaultValueCache.getInstance() || parameters.customDefaults) {
|
||||
def defaultValues = [:]
|
||||
|
@ -1,12 +1,32 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.sap.piper.GenerateDocumentation
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.Utils
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
@Field Set GENERAL_CONFIG_KEYS = ['collectTelemetryData']
|
||||
|
||||
@Field Set GENERAL_CONFIG_KEYS = [
|
||||
/** */
|
||||
'collectTelemetryData'
|
||||
]
|
||||
|
||||
@Field Set STEP_CONFIG_KEYS = []
|
||||
|
||||
@Field Set PARAMETER_KEYS = [
|
||||
/** Property file defining project specific settings.*/
|
||||
'configFile'
|
||||
]
|
||||
|
||||
/**
|
||||
* Initializes the [`commonPipelineEnvironment`](commonPipelineEnvironment.md), which is used throughout the complete pipeline.
|
||||
*
|
||||
* !!! tip
|
||||
* This step needs to run at the beginning of a pipeline right after the SCM checkout.
|
||||
* Then subsequent pipeline steps consume the information from `commonPipelineEnvironment`; it does not need to be passed to pipeline steps explicitly.
|
||||
*/
|
||||
@GenerateDocumentation
|
||||
void call(Map parameters = [:]) {
|
||||
|
||||
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
||||
|
@ -2,6 +2,7 @@ import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
import com.cloudbees.groovy.cps.NonCPS
|
||||
|
||||
import com.sap.piper.GenerateDocumentation
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.JenkinsUtils
|
||||
import com.sap.piper.MapUtils
|
||||
@ -9,22 +10,46 @@ import com.sap.piper.Utils
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field List TOOLS = [
|
||||
'junit','jacoco','cobertura','jmeter'
|
||||
/**
|
||||
* Publishes test results files in JUnit format with the [JUnit Plugin](https://plugins.jenkins.io/junit).
|
||||
* @possibleValues `true`, `false`, `Map`
|
||||
*/
|
||||
'junit',
|
||||
/**
|
||||
* Publishes code coverage with the [JaCoCo plugin](https://plugins.jenkins.io/jacoco).
|
||||
* @possibleValues `true`, `false`, `Map`
|
||||
*/
|
||||
'jacoco',
|
||||
/**
|
||||
* Publishes code coverage with the [Cobertura plugin](https://plugins.jenkins.io/cobertura).
|
||||
* @possibleValues `true`, `false`, `Map`
|
||||
*/
|
||||
'cobertura',
|
||||
/**
|
||||
* Publishes performance test results with the [Performance plugin](https://plugins.jenkins.io/performance).
|
||||
* @possibleValues `true`, `false`, `Map`
|
||||
*/
|
||||
'jmeter'
|
||||
]
|
||||
|
||||
@Field def STEP_NAME = getClass().getName()
|
||||
|
||||
@Field Set GENERAL_CONFIG_KEYS = TOOLS
|
||||
|
||||
@Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus([
|
||||
/**
|
||||
* If it is set to `true` the step will fail the build if JUnit detected any failing tests.
|
||||
* @possibleValues `true`, `false`
|
||||
*/
|
||||
'failOnError'
|
||||
])
|
||||
|
||||
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
|
||||
|
||||
/**
|
||||
* testResultsPublish
|
||||
*
|
||||
* @param script global script environment of the Jenkinsfile run
|
||||
* @param others document all parameters
|
||||
* This step can publish test results from various sources.
|
||||
*/
|
||||
@GenerateDocumentation
|
||||
void call(Map parameters = [:]) {
|
||||
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
||||
def script = checkScript(this, parameters) ?: this
|
||||
|
Loading…
x
Reference in New Issue
Block a user