1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/documentation/docs/steps/newmanExecute.md
lndrschlz dea96a3ba0
feat(newmanExecute): golang implmementation for newmanExecute (#2513)
* Automates first parts of newmanExecute.groovy

Signed-off-by: Fabian Reh <fabian.reh@sap.com>

* Adds newman installation

Signed-off-by: Fabian Reh <fabian.reh@sap.com>

* Removes warning

Signed-off-by: Fabian Reh <fabian.reh@sap.com>

* makes tests robust for later shell calls

Signed-off-by: Fabian Reh <fabian.reh@sap.com>

* Adds version logging

Signed-off-by: Fabian Reh <fabian.reh@sap.com>

* Adds tests for version logging

Signed-off-by: Fabian Reh <fabian.reh@sap.com>

* Adds newman shell execution

Signed-off-by: Fabian Reh <fabian.reh@sap.com>

* Prepare cloud foundry apps with secrets handling

Signed-off-by: Fabian Reh <fabian.reh@sap.com>

* Adds further process to CF Utils

Signed-off-by: Fabian Reh <fabian.reh@sap.com>

* Fixes unit test

Signed-off-by: Fabian Reh <fabian.reh@sap.com>

* Adds error category

Signed-off-by: Fabian Reh <fabian.reh@sap.com>

* Add fix to execute step locally

Currently only tested on windows machine locally in powershell.

Signed-off-by: Fabian Reh <fabian.reh@sap.com>

* Adapt unit test to fix of runCommand

Signed-off-by: Fabian Reh <fabian.reh@sap.com>

* refactored golang step to newmanExecute

* wip

* added test config

* refactored newmanExecute groovy wrapper step

* exclude newmanExecute from common step test

* cleaups

* add credential support

* fix groovy credential providing

* add import

* add stageName

* define script

* remove unused vars

* add import

* fix iterator ref

* golang secret handling and cleanups

* wip

* wip

* wip

* update go step

* implement cf credential proposal

* testRepository functionality implemented

* register secrets to logger

* add missing dependecies

* test xsuaa credential handling

* wip

* wip

* cleanups

* add import

* remove mandatory params

* add container definition

* test runCommand

* test runCommand

* fix npm path

* fix npm path

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* added newmanEnvironment to templating

* wip

* use env and globals params in runCommand when no templating

* fix condition

* wip

* reverted config edit

* updated documentation

* install with shell

* wip

* wip

* fix tests

* refactor tests

* wip

* remove old test

* wip

* escape go tmpl

* escape go tmpl

* fix defaults

* add doc comment

* remove test case

* refactored newman commands

* add cli reporter

* refactor options

* mock os getenv and fix all tests

* refactoring and doc update

* go generate

* small refactor

* spelling

* fix newman doc

* remove MaskPasswords wrapper; fix stash bug;

* docu fix

Co-authored-by: Fabian Reh <fabian.reh@sap.com>
2021-03-17 08:08:33 +01:00

2.7 KiB

${docGenStepName}

!!! warning "Deprecation notice" Details of changes after the step migration to a golang can be found below.

${docGenDescription}

Prerequisites

  • prepared Postman with a test collection

${docGenParameters}

${docGenConfiguration}

Side effects

Step uses dockerExecute inside.

${docJenkinsPluginDependencies}

Exceptions

The step has been migrated into a golang-based step. The following release notes belong to the new implementation:

  • newmanRunCommand:

The parameter newmanRunCommand is deprecated by now and is replaced by list parameter runOptions. For backward compatibility, the newmanRunCommand parameter will still be used if configured. Nevertheless, using this parameter can break the step in some cases, e.g. when spaces are used in single quoted strings like spaces in file names. Also Groovy Templating is deprecated and now replaced by Go Templating. The example show the required changes:

# deprecated groovy default
newmanRunCommand: "run '${config.newmanCollection}' --environment '${config.newmanEnvironment}' --globals '${config.newmanGlobals}' --reporters junit,html --reporter-junit-export 'target/newman/TEST-${collectionDisplayName}.xml' --reporter-html-export 'target/newman/TEST-${collectionDisplayName}.html'"
# new run options using golang templating
{{`runOptions: ["run", "{{.NewmanCollection}}", "--environment", "{{.Config.NewmanEnvironment}}", "--globals", "{{.Config.NewmanGlobals}}", "--reporters", "junit,html", "--reporter-junit-export", "target/newman/TEST-{{.CollectionDisplayName}}.xml", "--reporter-html-export", "target/newman/TEST-{{.CollectionDisplayName}}.html"]`}}

If the following error occurs during the pipeline run, the newmanRunCommand is probably still configured with the deprecated groovy template syntax:

info newmanExecute - error: collection could not be loaded info newmanExecute - unable to read data from file "${config.newmanCollection}" info newmanExecute - ENOENT: no such file or directory, open '${config.newmanCollection}'

  • newmanEnvironment and newmanGlobals:

Referencing newmanEnvironment and newmanGlobals in the runOptions is redundant now. Both parameters are added to runCommand using newmanEnvironment and newmanGlobals from config when configured and not referenced by go templating using "--environment", "{{{{.Config.NewmanEnvironment}}}}" and "--globals", "{{{{.Config.NewmanGlobals}}}}" as shown above.

Example

Pipeline step:

newmanExecute script: this

This step should be used in combination with testsPublishResults:

newmanExecute script: this, failOnError: false
testsPublishResults script: this, junit: [pattern: '**/newman/TEST-*.xml']