1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-18 05:18:24 +02:00

Merge branch 'master' into whitesource-step

This commit is contained in:
Oliver Nocon 2019-03-26 16:46:45 +01:00 committed by GitHub
commit 27c4db47e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 184 additions and 294 deletions

View File

@ -25,7 +25,7 @@ function notify() {
}
function cleanup() {
[ -z "${notificationThreadPid}" ] || kill -PIPE "${notificationThreadPid}" &>/dev/null
[[ -z "${notificationThreadPid}" ]] || kill -PIPE "${notificationThreadPid}" &>/dev/null
}
trap cleanup EXIT
@ -33,7 +33,7 @@ trap cleanup EXIT
#
# In case the build is performed for a pull request TRAVIS_COMMIT is a merge
# commit between the base branch and the PR branch HEAD. That commit is actually built.
# But for notifying about a build status we need the commit which is currenty
# But for notifying about a build status we need the commit which is currently
# the HEAD of the PR branch.
#
# In case the build is performed for a simple branch (not associated with a PR)
@ -42,16 +42,16 @@ trap cleanup EXIT
# TRAVIS_COMMIT itself.
#
COMMIT_HASH_FOR_STATUS_NOTIFICATIONS="${TRAVIS_PULL_REQUEST_SHA}"
[ -z "${COMMIT_HASH_FOR_STATUS_NOTIFICATIONS}" ] && COMMIT_HASH_FOR_STATUS_NOTIFICATIONS="${TRAVIS_COMMIT}"
[[ -z "${COMMIT_HASH_FOR_STATUS_NOTIFICATIONS}" ]] && COMMIT_HASH_FOR_STATUS_NOTIFICATIONS="${TRAVIS_COMMIT}"
notify "pending" "Integration tests in progress." "${COMMIT_HASH_FOR_STATUS_NOTIFICATIONS}"
WORKSPACES_ROOT=workspaces
[ -e "${WORKSPACES_ROOT}" ] && rm -rf ${WORKSPACES_ROOT}
[[ -e "${WORKSPACES_ROOT}" ]] && rm -rf ${WORKSPACES_ROOT}
TEST_CASES=$(find testCases -name '*.yml')
# This auxiliar thread is needed in order to produce some output while the
# This auxiliary thread is needed in order to produce some output while the
# test are running. Otherwise the job will be canceled after 10 minutes without
# output.
while true; do sleep 10; echo "[INFO] Integration tests still running."; done &
@ -65,7 +65,7 @@ do
area=$(dirname "${f#*/}")
echo "[INFO] Running test case \"${testCase}\" in area \"${area}\"."
TEST_CASE_ROOT="${WORKSPACES_ROOT}/${area}/${testCase}"
[ -e "${TEST_CASE_ROOT}" ] && rm -rf "${TEST_CASE_ROOT}"
[[ -e "${TEST_CASE_ROOT}" ]] && rm -rf "${TEST_CASE_ROOT}"
mkdir -p "${TEST_CASE_ROOT}" || fail "Cannot create test case root directory for test case \"${testCase}\"." 1
source ./runTest.sh "${testCase}" "${TEST_CASE_ROOT}" &> "${TEST_CASE_ROOT}/log.txt" &
pid=$!
@ -74,7 +74,7 @@ do
let i=i+1
done
[ "${i}" == 0 ] && fail "No tests has been executed." 1
[[ "${i}" == 0 ]] && fail "No tests has been executed." 1
#
# wait for the test cases and cat the log
@ -112,7 +112,7 @@ do
area=$(dirname "${p%:*}")
testCase=$(basename "${p%:*}")
TEST_CASE_ROOT="${WORKSPACES_ROOT}/${area}/${testCase}"
if [ -f "${TEST_CASE_ROOT}/SUCCESS" ]
if [[ -f "${TEST_CASE_ROOT}/SUCCESS" ]]
then
status="SUCCESS"
else
@ -125,7 +125,7 @@ done
STATUS_DESCRIPTION="The integration tests failed."
STATUS_STATE="failure"
if [ "${failure}" == "false" ]
if [[ "${failure}" == "false" ]]
then
STATUS_DESCRIPTION="The integration tests succeeded."
STATUS_STATE="success"
@ -133,7 +133,7 @@ fi
notify "${STATUS_STATE}" "${STATUS_DESCRIPTION}" "${COMMIT_HASH_FOR_STATUS_NOTIFICATIONS}"
[ "${failure}" != "false" ] && fail "Integration tests failed." 1
[[ "${failure}" != "false" ]] && fail "Integration tests failed." 1
echo "[INFO] Integration tests succeeded."
exit 0

View File

@ -27,4 +27,4 @@ RC=$?
cd - &> /dev/null || { echo "[ERROR] change directory back into integration test root folder failed."; exit 1; }
[ "${RC}" == 0 ] && touch "${TEST_CASE_ROOT}/SUCCESS"
[[ "${RC}" == 0 ]] && touch "${TEST_CASE_ROOT}/SUCCESS"

View File

@ -1,14 +1,6 @@
# mailSendNotification
# ${docGenStepName}
## Description
Sends notifications to all potential culprits of a current or previous build failure plus to fixed list of recipients.
It will attach the current build log to the email.
Notifications are sent in following cases:
* current build failed or is unstable
* current build is successful and previous build failed or was unstable
## ${docGenDescription}
## Prerequsites
@ -22,60 +14,9 @@ Usage of pipeline step:
mailSendNotification script: this
```
## Parameters
## ${docGenParameters}
| parameter | mandatory | default | possible values |
| ----------|-----------|---------|-----------------|
|script|yes|||
|buildResult|no|||
|gitCommitId|no|`script.commonPipelineEnvironment.getGitCommitId()`||
|gitSshKeyCredentialsId|no|``||
|gitUrl|no|||
|notificationAttachment|no|`true`||
|notificationRecipients|no|||
|notifyCulprits|no|`true`||
|numLogLinesInBody|no|`100`||
|projectName|no|||
|wrapInNode|no|`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.
* `buildResult` may be used to overrule the build result coming from `currentBuild.result`. This is for example used in the step `pipelineRestartSteps`
* `gitCommitId` defines a dedicated git commitId for culprit retrieval.
* `gitUrl` and `gitCommitId` are used to retrieve culprit information.
* `gitSshKeyCredentialsId` only required if your git repository is protected. It defines the credentialsId for the git ssh credentials.
* `notificationAttachment` defines if the console log file should be attached to the notification mail.
* `notificationRecipients` defines the fixed list of recipient that always get the notification. In case you want to send the notification to the culprits only set it to an empty string `''`.
!!! note
Multiple recipients need to be separated with the `space` character.
In case you do not want to have any fixed recipients of the notifications leave the property empty.
* `notifyCulprits` defines if potential culprits should receive an email.
* `numLogLinesInBody` defines the number of log lines (=last lines of the log) which are included into the body of the notification email.
* `projectName` may be used to specify a different name in the email subject.
* `wrapInNode` needs to be set to `true` if step is used outside of a node context, e.g. post actions in a declarative pipeline script.
## 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||||
|buildResult||X|X|
|gitCommitId||X|X|
|gitSshKeyCredentialsId|X|X|X|
|gitUrl||X|X|
|notificationAttachment||X|X|
|notificationRecipients||X|X|
|notifyCulprits||X|X|
|numLogLinesInBody||X|X|
|projectName||X|X|
|wrapInNode||X|X|
## ${docGenConfiguration}
## Side effects

View File

@ -1,12 +1,22 @@
# newmanExecute
# ${docGenStepName}
## Description
## ${docGenDescription}
This script executes your [Postman](https://www.getpostman.com) tests from a collection via the [Newman](https://www.getpostman.com/docs/v6/postman/collection_runs/command_line_integration_with_newman) command line collection.
## Prerequisites
## Prequisites
* prepared Postman with a test collection
- prepared Postman with a test collection
## ${docGenParameters}
## ${docGenConfiguration}
## Side effects
Step uses `dockerExecute` inside.
## Exceptions
none
## Example
@ -22,51 +32,3 @@ This step should be used in combination with `testsPublishResults`:
newmanExecute script: this, failOnError: false
testsPublishResults script: this, junit: [pattern: '**/newman/TEST-*.xml']
```
## Parameters
| name | mandatory | default | possible values |
|------|-----------|---------|-----------------|
| `dockerImage` | no | | |
| `failOnError` | no | | `true`, `false` |
| `gitBranch` | no | | |
| `gitSshKeyCredentialsId` | no | | |
| `newmanCollection` | no | | |
| `newmanEnvironment` | no | | |
| `newmanGlobals` | no | | |
| `newmanRunCommand` | no | | |
| `script` | yes | | |
| `stashContent` | no | | |
| `testRepository` | no | | |
- `dockerImage` - Docker image for code execution.
- `failOnError` - Defines the behavior, in case tests fail.
- `gitBranch` - see `testRepository`
- `gitSshKeyCredentialsId` - see `testRepository`
- `newmanCollection` - The test collection that should be executed. This could also be a file pattern.
- `newmanEnvironment` - Specify an environment file path or URL. Environments provide a set of variables that one can use within collections. see also [Newman docs](https://github.com/postmanlabs/newman#newman-run-collection-file-source-options)
- `newmanGlobals` - Specify the file path or URL for global variables. Global variables are similar to environment variables but have a lower precedence and can be overridden by environment variables having the same name. see also [Newman docs](https://github.com/postmanlabs/newman#newman-run-collection-file-source-options)
- `newmanRunCommand` - The newman command that will be executed inside the docker container.
- `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 for retrieving, for example, configuration parameters.
- `stashContent` - If specific stashes should be considered for the tests, you can pass this via this parameter.
- `testRepository` - 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.
## 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 |
|-----------|---------|------|-------|
| `dockerImage` |  | X | X |
| `failOnError` |  | X | X |
| `gitBranch` |  | X | X |
| `gitSshKeyCredentialsId` |  | X | X |
| `newmanCollection` |  | X | X |
| `newmanEnvironment` |  | X | X |
| `newmanGlobals` |  | X | X |
| `newmanRunCommand` |  | X | X |
| `script` | X | X | X |
| `stashContent` |  | X | X |
| `testRepository` |  | X | X |

View File

@ -1,73 +1,33 @@
# slackSendNotification
# ${docGenStepName}
## Description
Sends notifications to the Slack channel about the build status.
Notification contains:
* Build status;
* Repo Owner;
* Repo Name;
* Branch Name;
* Jenkins Build Number;
* Jenkins Build URL.
## ${docGenDescription}
## Prerequisites
Installed and configured [Jenkins Slack plugin](https://github.com/jenkinsci/slack-plugin).
* Installed and configured [Jenkins Slack plugin](https://github.com/jenkinsci/slack-plugin).
## ${docGenParameters}
## ${docGenConfiguration}
## Example
Usage of pipeline step:
```groovy
try {
stage('..') {..}
stage('..') {..}
stage('..') {..}
currentBuild.result = 'SUCCESS'
} catch (Throwable err) {
currentBuild.result = 'FAILURE'
throw err
} finally {
stage('report') {
slackSendNotification script: this
pipeline {
agent any
stages {
stage('Build') {
steps {
echo "do something"
}
}
}
post {
always {
slackSendNotification script: this
}
}
}
```
## Parameters
| parameter | mandatory | default | possible values |
| ----------|-----------|---------|-----------------|
|script|yes|||
|baseUrl|no|||
|channel|no|||
|color|no|`${buildStatus == 'SUCCESS'?'#008000':'#E60000'}`||
|credentialsId|no|||
|message|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.
* `baseUrl` allows overriding the Slack Plugin Integration Base Url specified in the global configuration.
* `color` defines the message color.
* If `channel` is defined another than the default channel will be used.
* `credentialsId` defines the Jenkins credentialId which holds the Slack token
* With parameter `message` a custom message can be defined which is sent into the Slack channel.
## 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||||
|baseUrl||X|X|
|channel||X|X|
|color||X|X|
|credentialsId||X|X|
|message||X|X|

View File

@ -16,8 +16,8 @@ import static org.junit.Assert.assertNotNull
class SetupCommonPipelineEnvironmentTest extends BasePiperTest {
def usedConfigFile
def swaOldConfigUsed
private JenkinsStepRule stepRule = new JenkinsStepRule(this)
@ -28,6 +28,7 @@ class SetupCommonPipelineEnvironmentTest extends BasePiperTest {
@Before
void init() {
def examplePipelineConfig = new File('test/resources/test_pipeline_config.yml').text
helper.registerAllowedMethod("readYaml", [Map], { Map parameters ->
@ -38,14 +39,6 @@ class SetupCommonPipelineEnvironmentTest extends BasePiperTest {
usedConfigFile = parameters.file
return yamlParser.load(examplePipelineConfig)
})
helper.registerAllowedMethod("readProperties", [Map], { Map parameters ->
usedConfigFile = parameters.file
Properties props = new Properties()
props.setProperty('key', 'value')
return props
})
swaOldConfigUsed = null
}
@Test
@ -55,35 +48,12 @@ class SetupCommonPipelineEnvironmentTest extends BasePiperTest {
return path.endsWith('.pipeline/config.yml')
})
stepRule.step.setupCommonPipelineEnvironment(script: nullScript, utils: getSWAMockedUtils())
stepRule.step.setupCommonPipelineEnvironment(script: nullScript)
assertEquals(Boolean.FALSE.toString(), swaOldConfigUsed)
assertEquals('.pipeline/config.yml', usedConfigFile)
assertNotNull(nullScript.commonPipelineEnvironment.configuration)
assertEquals('develop', nullScript.commonPipelineEnvironment.configuration.general.productiveBranch)
assertEquals('my-maven-docker', nullScript.commonPipelineEnvironment.configuration.steps.mavenExecute.dockerImage)
}
@Test
void testIsPropertiesConfigurationAvailable() {
helper.registerAllowedMethod("fileExists", [String], { String path ->
return path.endsWith('.pipeline/config.properties')
})
stepRule.step.setupCommonPipelineEnvironment(script: nullScript, utils: getSWAMockedUtils())
assertEquals(Boolean.TRUE.toString(), swaOldConfigUsed)
assertEquals('.pipeline/config.properties', usedConfigFile)
assertNotNull(nullScript.commonPipelineEnvironment.configProperties)
assertEquals('value', nullScript.commonPipelineEnvironment.configProperties['key'])
}
private getSWAMockedUtils() {
new Utils() {
void pushToSWA(Map payload, Map config) {
SetupCommonPipelineEnvironmentTest.this.swaOldConfigUsed = payload.stepParam5
}
}
}
}

View File

@ -2,7 +2,6 @@ import com.sap.piper.ConfigurationLoader
import com.sap.piper.ConfigurationMerger
class commonPipelineEnvironment implements Serializable {
Map configProperties = [:]
//stores version of the artifact which is build during pipeline run
def artifactVersion
@ -44,7 +43,6 @@ class commonPipelineEnvironment implements Serializable {
appContainerProperties = [:]
artifactVersion = null
configProperties = [:]
configuration = [:]
gitCommitId = null
@ -74,17 +72,6 @@ class commonPipelineEnvironment implements Serializable {
return appContainerProperties[property]
}
def setConfigProperty(property, value) {
configProperties[property] = value
}
def getConfigProperty(property) {
if (configProperties[property] != null)
return configProperties[property].trim()
else
return configProperties[property]
}
// goes into measurement jenkins_data
def setInfluxCustomDataEntry(field, value) {
influxCustomData[field] = value

View File

@ -1,26 +1,80 @@
import static com.sap.piper.Prerequisites.checkScript
import com.sap.piper.ConfigurationHelper
import com.sap.piper.GenerateDocumentation
import com.sap.piper.Utils
import groovy.text.SimpleTemplateEngine
import groovy.transform.Field
@Field String STEP_NAME = getClass().getName()
@Field Set GENERAL_CONFIG_KEYS = ['gitSshKeyCredentialsId']
@Field Set STEP_CONFIG_KEYS = [
'projectName',
'buildResult',
'gitUrl',
'gitCommitId',
'gitSshKeyCredentialsId',
'wrapInNode',
'notifyCulprits',
'notificationAttachment',
'notificationRecipients',
'numLogLinesInBody'
@Field Set GENERAL_CONFIG_KEYS = [
/**
* Only if `notifyCulprits` is set:
* Credentials if the repository is protected.
* @possibleValues Jenkins credentials id
*/
'gitSshKeyCredentialsId'
]
@Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus([
/**
* Set the build result used to determine the mail template.
* default `currentBuild.result`
*/
'buildResult',
/**
* Only if `notifyCulprits` is set:
* Defines a dedicated git commitId for culprit retrieval.
* default `commonPipelineEnvironment.getGitCommitId()`
*/
'gitCommitId',
/**
* Only if `notifyCulprits` is set:
* Repository url used to retrieve culprit information.
* default `commonPipelineEnvironment.getGitSshUrl()`
*/
'gitUrl',
/**
* defines if the console log file should be attached to the notification mail.
* @possibleValues `true`, `false`
*/
'notificationAttachment',
/**
* A space-separated list of recipients that always get the notification.
*/
'notificationRecipients',
/**
* Notify all committers since the last successful build.
* @possibleValues `true`, `false`
*/
'notifyCulprits',
/**
* Number of log line which are included in the email body.
*/
'numLogLinesInBody',
/**
* The project name used in the email subject.
* default `currentBuild.fullProjectName`
*/
'projectName',
/**
* Needs to be set to `true` if step is used outside of a node context, e.g. post actions in a declarative pipeline script.
* default `false`
* @possibleValues `true`, `false`
*/
'wrapInNode'
])
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
/**
* Sends notifications to all potential culprits of a current or previous build failure and to fixed list of recipients.
* It will attach the current build log to the email.
*
* Notifications are sent in following cases:
*
* * current build failed or is unstable
* * current build is successful and previous build failed or was unstable
*/
@GenerateDocumentation
void call(Map parameters = [:]) {
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters, allowBuildFailure: true) {
def script = checkScript(this, parameters) ?: this

View File

@ -1,6 +1,7 @@
import static com.sap.piper.Prerequisites.checkScript
import com.sap.piper.ConfigurationHelper
import com.sap.piper.GenerateDocumentation
import com.sap.piper.GitUtils
import com.sap.piper.Utils
import groovy.text.SimpleTemplateEngine
@ -11,58 +12,61 @@ import groovy.transform.Field
@Field Set GENERAL_CONFIG_KEYS = STEP_CONFIG_KEYS
@Field Set STEP_CONFIG_KEYS = [
/**
* Docker image for code execution.
*/
/** @see dockerExecute */
'dockerImage',
/**
* Defines the behavior, in case tests fail.
* @possibleValues `true`, `false`
*/
* Defines the behavior, in case tests fail.
* @possibleValues `true`, `false`
*/
'failOnError',
/**
* see `testRepository`
*/
* Only if `testRepository` is provided: Branch of testRepository, defaults to master.
*/
'gitBranch',
/**
* see `testRepository`
*/
* Only if `testRepository` is provided: Credentials for a protected testRepository
* @possibleValues Jenkins credentials id
*/
'gitSshKeyCredentialsId',
/**
* The test collection that should be executed. This could also be a file pattern.
*/
* The test collection that should be executed. This could also be a file pattern.
*/
'newmanCollection',
/**
* Specify an environment file path or URL. Environments provide a set of variables that one can use within collections.
* see also [Newman docs](https://github.com/postmanlabs/newman#newman-run-collection-file-source-options)
*/
* Specify an environment file path or URL. Environments provide a set of variables that one can use within collections.
* see also [Newman docs](https://github.com/postmanlabs/newman#newman-run-collection-file-source-options)
*/
'newmanEnvironment',
/**
* Specify the file path or URL for global variables. Global variables are similar to environment variables but have a lower precedence and can be overridden by environment variables having the same name.
* see also [Newman docs](https://github.com/postmanlabs/newman#newman-run-collection-file-source-options)
*/
* Specify the file path or URL for global variables. Global variables are similar to environment variables but have a lower precedence and can be overridden by environment variables having the same name.
* see also [Newman docs](https://github.com/postmanlabs/newman#newman-run-collection-file-source-options)
*/
'newmanGlobals',
/**
* The shell command that will be executed inside the docker container to install Newman.
*/
* The shell command that will be executed inside the docker container to install Newman.
*/
'newmanInstallCommand',
/**
* The newman command that will be executed inside the docker container.
*/
* The newman command that will be executed inside the docker container.
*/
'newmanRunCommand',
/**
* If specific stashes should be considered for the tests, you can pass this via this parameter.
*/
* If specific stashes should be considered for the tests, you can pass this via this parameter.
*/
'stashContent',
/**
* 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.
*/
* Define an additional repository where the test implementation is located.
* For protected repositories the `testRepository` needs to contain the ssh git url.
*/
'testRepository'
]
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
/**
* This script executes [Postman](https://www.getpostman.com) tests from a collection via the [Newman](https://www.getpostman.com/docs/v6/postman/collection_runs/command_line_integration_with_newman) command line tool.
*/
@GenerateDocumentation
void call(Map parameters = [:]) {
handlePipelineStepErrors(stepName: STEP_NAME, stepParameters: parameters) {

View File

@ -27,9 +27,7 @@ void call(Map parameters = [:]) {
(parameters.utils ?: new Utils()).pushToSWA([
step: STEP_NAME,
stepParamKey4: 'customDefaults',
stepParam4: parameters.customDefaults?'true':'false',
stepParamKey5: 'legacyConfig',
stepParam5: Boolean.toString( ! (script?.commonPipelineEnvironment?.getConfigProperties() ?: [:]).isEmpty())
stepParam4: parameters.customDefaults?'true':'false'
], config)
script.commonPipelineEnvironment.setInfluxStepData('build_url', env.BUILD_URL)
@ -37,28 +35,11 @@ void call(Map parameters = [:]) {
}
}
private boolean isYaml(String fileName) {
return fileName.endsWith(".yml") || fileName.endsWith(".yaml")
}
private boolean isProperties(String fileName) {
return fileName.endsWith(".properties")
}
private loadConfigurationFromFile(script, String configFile) {
String defaultPropertiesConfigFile = '.pipeline/config.properties'
String defaultYmlConfigFile = '.pipeline/config.yml'
if (configFile?.trim()?.length() > 0 && isProperties(configFile)) {
Map configMap = readProperties(file: configFile)
script.commonPipelineEnvironment.setConfigProperties(configMap)
} else if (fileExists(defaultPropertiesConfigFile)) {
Map configMap = readProperties(file: defaultPropertiesConfigFile)
script.commonPipelineEnvironment.setConfigProperties(configMap)
}
if (configFile?.trim()?.length() > 0 && isYaml(configFile)) {
if (configFile) {
script.commonPipelineEnvironment.configuration = readYaml(file: configFile)
} else if (fileExists(defaultYmlConfigFile)) {
script.commonPipelineEnvironment.configuration = readYaml(file: defaultYmlConfigFile)

View File

@ -1,6 +1,7 @@
import static com.sap.piper.Prerequisites.checkScript
import com.sap.piper.ConfigurationHelper
import com.sap.piper.GenerateDocumentation
import com.sap.piper.Utils
import groovy.transform.Field
import groovy.text.SimpleTemplateEngine
@ -9,14 +10,44 @@ import groovy.text.SimpleTemplateEngine
@Field Set GENERAL_CONFIG_KEYS = []
@Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus([
/**
* Allows overriding the Slack Plugin Integration Base Url specified in the global configuration.
*/
'baseUrl',
/**
* Allows overriding of the default massaging channel from the plugin configuration.
*/
'channel',
/**
* Defines the message color`color` defines the message color.
* @possibleValues one of `good`, `warning`, `danger`, or any hex color code (eg. `#439FE0`)
*/
'color',
/**
* The credentials id for the Slack token.
* @possibleValues Jenkins credentials id
*/
'credentialsId',
/**
* Send a custom message into the Slack channel.
*/
'message'
])
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
/**
* Sends notifications to the Slack channel about the build status.
*
* Notification contains:
*
* * Build status;
* * Repo Owner;
* * Repo Name;
* * Branch Name;
* * Jenkins Build Number;
* * Jenkins Build URL.
*/
@GenerateDocumentation
void call(Map parameters = [:]) {
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
def utils = parameters.juStabUtils ?: new Utils()