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/uiVeri5ExecuteTests.md
Christopher Fenner 1514be9857
chore: fix markdownlint findings (#2385)
* activate MD022

* fix MD022 findings

* activate MD030

* fix MD030 findings

* activate MD038

* fix MD038 findings

* activate MD031

* fix MD031 findings

* activate MD042

* fix MD042 findings

* activate MD032

* fix MD032 findings

* activate MD039

* activate MD007

* fix MD007 findings

* activate MD026

* fix MD026 findings

* activate MD001

* fix MD001 findings

* acknowledge disabled rules

* fix code climate MD032 finding
2020-11-17 09:20:47 +01:00

91 lines
3.4 KiB
Markdown

# ${docGenStepName}
## ${docGenDescription}
## Prerequisites
## ${docGenParameters}
## ${docGenConfiguration}
## ${docJenkinsPluginDependencies}
## Exceptions
If you see an error like `fatal: Not a git repository (or any parent up to mount point /home/jenkins)` it is likely that your test description cannot be found.<br />
Please make sure to point parameter `testOptions` to your `conf.js` file like `testOptions: './path/to/my/tests/conf.js'`
## Examples
### Passing credentials from Jenkins
When running acceptance tests in a real environment, authentication will be enabled in most cases. UIVeri5 includes [features to automatically perform the login](https://github.com/SAP/ui5-uiveri5/blob/master/docs/config/authentication.md) with credentials in the `conf.js`. However, having credentials to the acceptance system stored in plain text is not an optimal solution.
Therefore, UIVeri5 allows templating to set parameters at runtime, as shown in the following example `conf.js`:
```js
// Read environment variables
const defaultParams = {
url: process.env.TARGET_SERVER_URL,
user: process.env.TEST_USER,
pass: process.env.TEST_PASS
};
// Resolve path to specs relative to the working directory
const path = require('path');
const specs = path.relative(process.cwd(), path.join(__dirname, '*.spec.js'));
// export UIVeri5 config
exports.config = {
profile: 'integration',
baseUrl: '\${params.url}',
specs: specs,
params: defaultParams, // can be overridden via cli `--params.<key>=<value>`
auth: {
// set up authorization for CF XSUAA
'sapcloud-form': {
user: '\${params.user}',
pass: '\${params.pass}',
userFieldSelector: 'input[name="username"]',
passFieldSelector: 'input[name="password"]',
logonButtonSelector: 'input[type="submit"]',
redirectUrl: /cp.portal\/site/
}
}
};
```
While default values for `baseUrl`, `user` and `pass` are read from the environment, they can also be overridden when calling the CLI.
In a custom Pipeline, this is very simple: Just wrap the call to `uiVeri5ExecuteTests` in `withCredentials` (`TARGET_SERVER_URL` is read from `config.yml`):
```groovy
withCredentials([usernamePassword(
credentialsId: 'MY_ACCEPTANCE_CREDENTIALS',
passwordVariable: 'password',
usernameVariable: 'username'
)]) {
uiVeri5ExecuteTests script: this, testOptions: "./uiveri5/conf.js --params.user=\${username} --params.pass=\${password}"
}
```
In a Pipeline Template, a [Stage Exit](../extensibility/#1-extend-individual-stages) can be used to fetch the credentials and store them in the environment. As the environment is passed down to uiVeri5ExecuteTests, the variables will be present there. This is an example for the stage exit `.pipeline/extensions/Acceptance.groovy` where the `credentialsId` is read from the `config.yml`:
```groovy
void call(Map params) {
// read username and password from the credential store
withCredentials([usernamePassword(
credentialsId: params.config.acceptanceCredentialsId,
passwordVariable: 'password',
usernameVariable: 'username'
)]) {
// store the result in the environment variables for executeUIVeri5Test
withEnv(["TEST_USER=\${username}", "TEST_PASS=\${password}"]) {
//execute original stage as defined in the template
params.originalStage()
}
}
}
return this
```