mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-18 05:18:24 +02:00
Merge remote-tracking branch 'github/master' into HEAD
This commit is contained in:
commit
cc971190c9
@ -1,6 +1,9 @@
|
||||
plugins:
|
||||
codenarc:
|
||||
enabled: true
|
||||
checks:
|
||||
BooleanGetBoolean:
|
||||
enabled: false
|
||||
editorconfig:
|
||||
enabled: true
|
||||
checks:
|
||||
|
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
@ -13,7 +13,7 @@ node {
|
||||
} catch (Throwable err) {
|
||||
echo "Error occured: ${err}"
|
||||
currentBuild.result = 'FAILURE'
|
||||
mail subject: '[Build failed] SAP/jenkins-library', body: 'Fix the build.', to: 'k.arnold@sap.com,marcus.holl@sap.com,oliver.nocon@sap.com'
|
||||
mail subject: '[Build failed] SAP/jenkins-library', body: 'Fix the build.', to: 'marcus.holl@sap.com,oliver.nocon@sap.com'
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ To setup the shared library, you need to perform the following steps:
|
||||
1. Open the system configuration page (*Manage Jenkins > Configure System*).
|
||||
1. Scroll down to section *Global Pipeline Libraries* and add a new Library by
|
||||
clicking the *Add* button.
|
||||
1. set *Library Name* to `piper-library-os`
|
||||
1. set *Library Name* to `piper-lib-os`
|
||||
1. set *Default Version* to the branch or tag you want to consume (e.g.
|
||||
`master` or `v0.1`)
|
||||
1. set *Retrieval Method* to `Modern SCM`
|
||||
@ -82,11 +82,11 @@ To setup the shared library, you need to perform the following steps:
|
||||
|
||||
![Library Setup](./documentation/docs/images/setupInJenkins.png)
|
||||
|
||||
Now the library is available as `piper-library-os` and can be used in any
|
||||
Now the library is available as `piper-lib-os` and can be used in any
|
||||
`Jenkinsfile` by adding this line:
|
||||
|
||||
```groovy
|
||||
@Library('piper-library-os') _
|
||||
@Library('piper-lib-os') _
|
||||
```
|
||||
|
||||
Jenkins will download the library during execution of the `Jenkinsfile`.
|
||||
|
@ -44,7 +44,7 @@ class TemplateHelper {
|
||||
parameters.keySet().toSorted().each {
|
||||
|
||||
def props = parameters.get(it)
|
||||
t += "| `${it}` | ${props.required ? 'yes' : 'no'} | ${(props.defaultValue ? '`' + props.defaultValue + '`' : '') } | ${props.value ?: ''} |\n"
|
||||
t += "| `${it}` | ${props.mandatory ?: props.required ? 'yes' : 'no'} | ${(props.defaultValue ? '`' + props.defaultValue + '`' : '') } | ${props.value ?: ''} |\n"
|
||||
}
|
||||
|
||||
t
|
||||
@ -65,7 +65,7 @@ class TemplateHelper {
|
||||
def t = '''|
|
||||
|We recommend to define values of step parameters via [config.yml file](../configuration.md).
|
||||
|
|
||||
|In following sections the configuration is possible:'''.stripMargin()
|
||||
|In following sections the configuration is possible:\n\n'''.stripMargin()
|
||||
|
||||
t += '| parameter | general | step | stage |\n'
|
||||
t += '|-----------|---------|------|-------|\n'
|
||||
@ -91,7 +91,7 @@ class Helper {
|
||||
|
||||
new GroovyClassLoader(classLoader, compilerConfig, true)
|
||||
.parseClass(new File('src/com/sap/piper/ConfigurationHelper.groovy'))
|
||||
.newInstance(script, [:])
|
||||
.newInstance(script, [:]).loadStepDefaults()
|
||||
}
|
||||
|
||||
static getPrepareDefaultValuesStep(def gse) {
|
||||
@ -195,9 +195,10 @@ class Helper {
|
||||
|
||||
boolean docu = false,
|
||||
value = false,
|
||||
mandatory = false,
|
||||
docuEnd = false
|
||||
|
||||
def docuLines = [], valueLines = []
|
||||
def docuLines = [], valueLines = [], mandatoryLines = []
|
||||
|
||||
f.eachLine {
|
||||
line ->
|
||||
@ -221,14 +222,17 @@ class Helper {
|
||||
if(step.parameters[param].docu || step.parameters[param].value)
|
||||
System.err << "[WARNING] There is already some documentation for parameter '${param}. Is this parameter documented twice?'\n"
|
||||
|
||||
def _docu = [], _value = []
|
||||
def _docu = [], _value = [], _mandatory = []
|
||||
docuLines.each { _docu << it }
|
||||
valueLines.each { _value << it}
|
||||
mandatoryLines.each { _mandatory << it}
|
||||
step.parameters[param].docu = _docu*.trim().join(' ').trim()
|
||||
step.parameters[param].value = _value*.trim().join(' ').trim()
|
||||
step.parameters[param].mandatory = _mandatory*.trim().join(' ').trim()
|
||||
}
|
||||
docuLines.clear()
|
||||
valueLines.clear()
|
||||
mandatoryLines.clear()
|
||||
}
|
||||
|
||||
if( line.trim() ==~ /^\/\*\*/ ) {
|
||||
@ -242,15 +246,30 @@ class Helper {
|
||||
if(_line.startsWith('*/')) _line = _line.replaceAll('^\\*/', '') // end comment
|
||||
if(_line.startsWith('*')) _line = _line.replaceAll('^\\*', '') // continue comment
|
||||
if(_line ==~ /.*@possibleValues.*/) {
|
||||
mandatory = false // should be something like reset attributes
|
||||
value = true
|
||||
}
|
||||
// some remark for mandatory e.g. some parameters are only mandatory under certain conditions
|
||||
if(_line ==~ /.*@mandatory.*/) {
|
||||
value = false // should be something like reset attributes ...
|
||||
mandatory = true
|
||||
}
|
||||
|
||||
if(value) {
|
||||
if(_line) {
|
||||
_line = (_line =~ /.*@possibleValues\s*?(.*)/)[0][1]
|
||||
valueLines << _line
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
if(mandatory) {
|
||||
if(_line) {
|
||||
_line = (_line =~ /.*@mandatory\s*?(.*)/)[0][1]
|
||||
mandatoryLines << _line
|
||||
}
|
||||
}
|
||||
|
||||
if(! value && ! mandatory) {
|
||||
docuLines << _line.trim()
|
||||
}
|
||||
}
|
||||
@ -258,14 +277,15 @@ class Helper {
|
||||
if(docu && line.trim() ==~ /^\*\//) {
|
||||
docu = false
|
||||
value = false
|
||||
mandatory = false
|
||||
docuEnd = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static isHeader(line) {
|
||||
Matcher headerMatcher = (line =~ /(def|void)\s*call\s*\(/ )
|
||||
return headerMatcher.size() == 1 && headerMatcher[0].size() == 2
|
||||
Matcher headerMatcher = (line =~ /(?:(?:def|void)\s*call\s*\()|(?:@.*)/ )
|
||||
return headerMatcher.size() == 1
|
||||
}
|
||||
|
||||
private static retrieveParameterName(line) {
|
||||
@ -465,7 +485,7 @@ def handleStep(stepName, prepareDefaultValuesStep, gse) {
|
||||
step.parameters['script'] = [
|
||||
docu: '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. ' +
|
||||
'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.',
|
||||
required: true,
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 35 KiB |
@ -45,7 +45,7 @@ The step is configured using a customer configuration file provided as
|
||||
resource in an custom shared library.
|
||||
|
||||
```groovy
|
||||
@Library('piper-library-os@master') _
|
||||
@Library('piper-lib-os@master') _
|
||||
|
||||
// the shared lib containing the additional configuration
|
||||
// needs to be configured in Jenkins
|
||||
|
@ -144,10 +144,6 @@ checksPublishResults(
|
||||
|
||||
![StaticChecks Thresholds](../images/StaticChecks_Threshold.png)
|
||||
|
||||
## Return value
|
||||
|
||||
none
|
||||
|
||||
## Side effects
|
||||
|
||||
If both ESLint and PyLint results are published, they are not correctly aggregated in the aggregator plugin.
|
||||
|
@ -29,6 +29,7 @@ Deployment can be done
|
||||
| cloudFoundry | yes | | |
|
||||
| deployTool | no | cf_native | cf_native, mtaDeployPlugin |
|
||||
| deployType | no | standard | standard, blue-green |
|
||||
| keepOldInstance | no | false | true, false |
|
||||
| dockerImage | no | s4sdk/docker-cf-cli | |
|
||||
| dockerWorkspace | no | /home/piper | |
|
||||
| mtaDeployParameters | | -f | |
|
||||
@ -65,6 +66,7 @@ Deployment can be done
|
||||
|
||||
* `deployTool` defines the tool which should be used for deployment.
|
||||
* `deployType` defines the type of deployment, either `standard` deployment which results in a system downtime or a zero-downtime `blue-green` deployment.
|
||||
* `keepOldInstance` in case of a `blue-green` deployment the old instance will be deleted by default. If this option is set to true the old instance will remain stopped in the Cloud Foundry space.
|
||||
* `dockerImage` defines the Docker image containing the deployment tools (like cf cli, ...) and `dockerWorkspace` defines the home directory of the default user of the `dockerImage`
|
||||
* `smokeTestScript` allows to specify a script which performs a check during blue-green deployment. The script gets the FQDN as parameter and returns `exit code 0` in case check returned `smokeTestStatusCode`. More details can be found [here](https://github.com/bluemixgaragelondon/cf-blue-green-deploy#how-to-use) <br /> Currently this option is only considered for deployTool `cf_native`.
|
||||
* `stashContent` defines the stash names which should be unstashed at the beginning of the step. This makes the files available in case the step is started on an empty node.
|
||||
|
@ -69,10 +69,6 @@ In following sections the configuration is possible:
|
||||
|sidecarVolumeBind||X|X|
|
||||
|sidecarWorkspace||X|X|
|
||||
|
||||
## Return value
|
||||
|
||||
none
|
||||
|
||||
## Side effects
|
||||
|
||||
none
|
||||
|
@ -64,10 +64,6 @@ In following sections the configuration is possible:
|
||||
|stashExcludes||X|X|
|
||||
|stashIncludes||X|X|
|
||||
|
||||
## Return value
|
||||
|
||||
none
|
||||
|
||||
## Side effects
|
||||
|
||||
none
|
||||
|
@ -46,10 +46,6 @@ none
|
||||
|
||||
none
|
||||
|
||||
## Return value
|
||||
|
||||
none
|
||||
|
||||
## Side effects
|
||||
|
||||
none
|
||||
|
@ -25,7 +25,7 @@ In the Docker network, the containers can be referenced by the values provided i
|
||||
| ----------|-----------|---------|-----------------|
|
||||
|script|yes|||
|
||||
|containerPortMappings|no|`[node:8-stretch: [[containerPort: 9876, hostPort: 9876]]]`||
|
||||
|dockerEnvVars|no|||
|
||||
|dockerEnvVars|no|`[ NO_PROXY: 'localhost,karma,$NO_PROXY', no_proxy: 'localhost,karma,$no_proxy']`||
|
||||
|dockerImage|no|`node:8-stretch`||
|
||||
|dockerName|no|`karma`||
|
||||
|dockerWorkspace|no|`/home/node`||
|
||||
@ -33,11 +33,11 @@ In the Docker network, the containers can be referenced by the values provided i
|
||||
|installCommand|no|`npm install --quiet`||
|
||||
|modules|no|`['.']`||
|
||||
|runCommand|no|`npm run karma`||
|
||||
|sidecarEnvVars|no|||
|
||||
|sidecarEnvVars|no|`[ NO_PROXY: 'localhost,selenium,$NO_PROXY', no_proxy: 'localhost,selenium,$no_proxy']`||
|
||||
|sidecarImage|no|||
|
||||
|sidecarName|no|||
|
||||
|sidecarVolumeBind|no|||
|
||||
|stashContent|no|||
|
||||
|stashContent|no|`['buildDescriptor', 'tests']`||
|
||||
|
||||
- `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.
|
||||
- `containerPortMappings` - see step [dockerExecute](dockerExecute.md)
|
||||
@ -79,10 +79,6 @@ In following sections the configuration is possible:
|
||||
|sidecarVolumeBind|X|X|X|
|
||||
|stashContent|X|X|X|
|
||||
|
||||
## Return value
|
||||
|
||||
none
|
||||
|
||||
## Side effects
|
||||
|
||||
Step uses `seleniumExecuteTest` & `dockerExecute` inside.
|
||||
|
@ -77,10 +77,6 @@ In following sections the configuration is possible:
|
||||
|projectName||X|X|
|
||||
|wrapInNode||X|X|
|
||||
|
||||
## Return value
|
||||
|
||||
none
|
||||
|
||||
## Side effects
|
||||
|
||||
none
|
||||
|
@ -48,10 +48,6 @@ The following parameters can also be specified as step parameters using the glob
|
||||
* `mtaJarLocation`
|
||||
* `applicationName`
|
||||
|
||||
## Return value
|
||||
|
||||
none
|
||||
|
||||
## Side effects
|
||||
|
||||
1. The file name of the resulting archive is written to the `commonPipelineEnvironment` with variable name `mtarFileName`.
|
||||
|
@ -95,10 +95,6 @@ The following parameters can also be specified as step parameters using the glob
|
||||
* `neoCredentialsId`
|
||||
* `neoHome`
|
||||
|
||||
## Return value
|
||||
|
||||
none
|
||||
|
||||
## Side effects
|
||||
|
||||
none
|
||||
|
@ -30,10 +30,6 @@ none
|
||||
|
||||
none
|
||||
|
||||
## Return value
|
||||
|
||||
none
|
||||
|
||||
## Side effects
|
||||
|
||||
none
|
||||
|
@ -63,10 +63,6 @@ In following sections the configuration is possible:
|
||||
|sendMail|X|X|X|
|
||||
|timeoutInSeconds|X|X|X|
|
||||
|
||||
## Return value
|
||||
|
||||
none
|
||||
|
||||
## Side effects
|
||||
|
||||
none
|
||||
|
@ -137,10 +137,6 @@ In following sections the configuration is possible:
|
||||
|stashContent|X|X|X|
|
||||
|testRepository|X|X|X|
|
||||
|
||||
## Return value
|
||||
|
||||
none
|
||||
|
||||
## Side effects
|
||||
|
||||
none
|
||||
|
@ -26,10 +26,6 @@ Initializes the [`commonPipelineEnvironment`](commonPipelineEnvironment.md), whi
|
||||
|
||||
none
|
||||
|
||||
## Return value
|
||||
|
||||
none
|
||||
|
||||
## Side effects
|
||||
|
||||
none
|
||||
|
@ -54,7 +54,7 @@ Each of the parameters `junit`, `jacoco`, `cobertura` and `jmeter` can be set to
|
||||
|
||||
| parameter | mandatory | default | possible values |
|
||||
| ----------|-----------|---------|-----------------|
|
||||
| pattern | no | `'**/target/surefire-reports/*.xml'` | |
|
||||
| pattern | no | `'**/TEST-*.xml'` | |
|
||||
| archive | no | `false` | true, false |
|
||||
| updateResults | no | `false` | true, false |
|
||||
| allowEmptyResults | no | `true` | true, false |
|
||||
@ -108,10 +108,6 @@ Following parameters can also be specified as step parameters using the global c
|
||||
* `cobertura`
|
||||
* `jmeter`
|
||||
|
||||
## Return value
|
||||
|
||||
none
|
||||
|
||||
## Side effects
|
||||
|
||||
none
|
||||
|
@ -23,10 +23,6 @@ none
|
||||
|
||||
none
|
||||
|
||||
## Return value
|
||||
|
||||
none
|
||||
|
||||
## Side effects
|
||||
|
||||
none
|
||||
|
@ -7,6 +7,8 @@ Creates
|
||||
* a Transport Request for a Change Document on the Solution Manager (type `SOLMAN`) or
|
||||
* a Transport Request inside an ABAP system (type`CTS`)
|
||||
|
||||
The id of the transport request is availabe via [commonPipelineEnvironment.getTransportRequestId()](commonPipelineEnvironment.md)
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* **[Change Management Client 2.0.0 or compatible version](http://central.maven.org/maven2/com/sap/devops/cmclient/dist.cli/)** - available for download on Maven Central.
|
||||
@ -49,7 +51,7 @@ The step is configured using a customer configuration file provided as
|
||||
resource in an custom shared library.
|
||||
|
||||
```groovy
|
||||
@Library('piper-library-os@master') _
|
||||
@Library('piper-lib-os@master') _
|
||||
|
||||
// the shared lib containing the additional configuration
|
||||
// needs to be configured in Jenkins
|
||||
@ -97,7 +99,7 @@ The parameters can also be provided when the step is invoked. For examples see b
|
||||
|
||||
## Return value
|
||||
|
||||
The id of the Transport Request that has been created.
|
||||
none
|
||||
|
||||
## Exceptions
|
||||
|
||||
|
@ -41,7 +41,7 @@ The step is configured using a customer configuration file provided as
|
||||
resource in an custom shared library.
|
||||
|
||||
```groovy
|
||||
@Library('piper-library-os@master') _
|
||||
@Library('piper-lib-os@master') _
|
||||
|
||||
// the shared lib containing the additional configuration
|
||||
// needs to be configured in Jenkins
|
||||
@ -86,10 +86,6 @@ The properties can also be configured on a per-step basis:
|
||||
|
||||
The parameters can also be provided when the step is invoked. For examples see below.
|
||||
|
||||
## Return value
|
||||
|
||||
None.
|
||||
|
||||
## Exceptions
|
||||
|
||||
* `IllegalArgumentException`:
|
||||
|
@ -46,7 +46,7 @@ The step is configured using a customer configuration file provided as
|
||||
resource in an custom shared library.
|
||||
|
||||
```groovy
|
||||
@Library('piper-library-os@master') _
|
||||
@Library('piper-lib-os@master') _
|
||||
|
||||
// the shared lib containing the additional configuration
|
||||
// needs to be configured in Jenkins
|
||||
@ -92,10 +92,6 @@ The properties can also be configured on a per-step basis:
|
||||
|
||||
The parameters can also be provided when the step is invoked. For examples see below.
|
||||
|
||||
## Return value
|
||||
|
||||
None.
|
||||
|
||||
## Exceptions
|
||||
|
||||
* `IllegalArgumentException`:
|
||||
|
@ -123,6 +123,7 @@ steps:
|
||||
apiEndpoint: 'https://api.cf.eu10.hana.ondemand.com'
|
||||
deployTool: 'cf_native'
|
||||
deployType: 'standard'
|
||||
keepOldInstance: false
|
||||
mtaDeployParameters: '-f'
|
||||
mtaExtensionDescriptor: ''
|
||||
mtaPath: ''
|
||||
@ -187,6 +188,9 @@ steps:
|
||||
'node:8-stretch':
|
||||
- containerPort: 9876
|
||||
hostPort: 9876
|
||||
dockerEnvVars:
|
||||
NO_PROXY: 'localhost,selenium,$NO_PROXY'
|
||||
no_proxy: 'localhost,selenium,$no_proxy'
|
||||
dockerImage: 'node:8-stretch'
|
||||
dockerName: 'karma'
|
||||
dockerWorkspace: '/home/node'
|
||||
@ -194,6 +198,12 @@ steps:
|
||||
modules:
|
||||
- '.'
|
||||
runCommand: 'npm run karma'
|
||||
sidecarEnvVars:
|
||||
NO_PROXY: 'localhost,karma,$NO_PROXY'
|
||||
no_proxy: 'localhost,karma,$no_proxy'
|
||||
stashContent:
|
||||
- buildDescriptor
|
||||
- tests
|
||||
mailSendNotification:
|
||||
notificationAttachment: true
|
||||
notifyCulprits: true
|
||||
@ -217,7 +227,8 @@ steps:
|
||||
newmanCollection: '**/*.postman_collection.json'
|
||||
newmanEnvironment: ''
|
||||
newmanGlobals: ''
|
||||
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"
|
||||
newmanInstallCommand: 'npm install newman newman-reporter-html --global --quiet'
|
||||
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'"
|
||||
stashContent:
|
||||
- 'tests'
|
||||
pipelineRestartSteps:
|
||||
@ -287,7 +298,7 @@ steps:
|
||||
toHtml: false
|
||||
testsPublishResults:
|
||||
junit:
|
||||
pattern: '**/target/surefire-reports/*.xml'
|
||||
pattern: '**/TEST-*.xml'
|
||||
updateResults: false
|
||||
allowEmptyResults: true
|
||||
archive: false
|
||||
|
@ -4,57 +4,64 @@ import com.cloudbees.groovy.cps.NonCPS
|
||||
|
||||
public class StepHelpers {
|
||||
|
||||
@NonCPS
|
||||
public static def getTransportRequestId(ChangeManagement cm, def step, Map configuration) {
|
||||
public static def getTransportRequestId(ChangeManagement cm, def script, Map configuration) {
|
||||
|
||||
def transportRequestId = configuration.transportRequestId
|
||||
|
||||
if(transportRequestId?.trim()) {
|
||||
|
||||
step.echo "[INFO] Transport request id '${transportRequestId}' retrieved from parameters."
|
||||
script.echo "[INFO] Transport request id '${transportRequestId}' retrieved from parameters."
|
||||
return transportRequestId
|
||||
|
||||
} else {
|
||||
|
||||
step.echo "[INFO] Retrieving transport request id from commit history [from: ${configuration.changeManagement.git.from}, to: ${configuration.changeManagement.git.to}]." +
|
||||
" Searching for pattern '${configuration.changeManagement.transportRequestLabel}'. Searching with format '${configuration.changeManagement.git.format}'."
|
||||
|
||||
try {
|
||||
transportRequestId = cm.getTransportRequestId(
|
||||
configuration.changeManagement.git.from,
|
||||
configuration.changeManagement.git.to,
|
||||
configuration.changeManagement.transportRequestLabel,
|
||||
configuration.changeManagement.git.format
|
||||
)
|
||||
|
||||
step.echo "[INFO] Transport request id '${transportRequestId}' retrieved from commit history"
|
||||
|
||||
} catch(ChangeManagementException ex) {
|
||||
step.echo "[WARN] Cannot retrieve transportRequestId from commit history: ${ex.getMessage()}."
|
||||
}
|
||||
}
|
||||
return transportRequestId
|
||||
|
||||
transportRequestId = script.commonPipelineEnvironment.getTransportRequestId()
|
||||
|
||||
if(transportRequestId?.trim()) {
|
||||
script.echo "[INFO] Transport request id '${transportRequestId}' retrieved from common pipeline environment."
|
||||
return transportRequestId
|
||||
}
|
||||
|
||||
script.echo "[INFO] Retrieving transport request id from commit history [from: ${configuration.changeManagement.git.from}, to: ${configuration.changeManagement.git.to}]." +
|
||||
" Searching for pattern '${configuration.changeManagement.transportRequestLabel}'. Searching with format '${configuration.changeManagement.git.format}'."
|
||||
|
||||
try {
|
||||
transportRequestId = cm.getTransportRequestId(
|
||||
configuration.changeManagement.git.from,
|
||||
configuration.changeManagement.git.to,
|
||||
configuration.changeManagement.transportRequestLabel,
|
||||
configuration.changeManagement.git.format
|
||||
)
|
||||
|
||||
script.commonPipelineEnvironment.setTransportRequestId(transportRequestId)
|
||||
script.echo "[INFO] Transport request id '${transportRequestId}' retrieved from commit history"
|
||||
|
||||
} catch(ChangeManagementException ex) {
|
||||
script.echo "[WARN] Cannot retrieve transportRequestId from commit history: ${ex.getMessage()}."
|
||||
}
|
||||
|
||||
transportRequestId
|
||||
}
|
||||
|
||||
@NonCPS
|
||||
public static getChangeDocumentId(ChangeManagement cm, def step, Map configuration) {
|
||||
public static getChangeDocumentId(ChangeManagement cm, def script, Map configuration) {
|
||||
|
||||
def changeDocumentId = configuration.changeDocumentId
|
||||
|
||||
if(changeDocumentId?.trim()) {
|
||||
|
||||
step.echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from parameters."
|
||||
script.echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from parameters."
|
||||
return changeDocumentId
|
||||
}
|
||||
|
||||
changeDocumentId = step.commonPipelineEnvironment.getChangeDocumentId()
|
||||
changeDocumentId = script.commonPipelineEnvironment.getChangeDocumentId()
|
||||
|
||||
if(changeDocumentId?.trim()) {
|
||||
|
||||
step.echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from common pipeline environment."
|
||||
script.echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from common pipeline environment."
|
||||
return changeDocumentId
|
||||
}
|
||||
|
||||
step.echo "[INFO] Retrieving ChangeDocumentId from commit history [from: ${configuration.changeManagement.git.from}, to: ${configuration.changeManagement.git.to}]." +
|
||||
script.echo "[INFO] Retrieving ChangeDocumentId from commit history [from: ${configuration.changeManagement.git.from}, to: ${configuration.changeManagement.git.to}]." +
|
||||
"Searching for pattern '${configuration.changeManagement.changeDocumentLabel}'. Searching with format '${configuration.changeManagement.git.format}'."
|
||||
|
||||
try {
|
||||
@ -65,31 +72,31 @@ public class StepHelpers {
|
||||
configuration.changeManagement.git.format
|
||||
)
|
||||
|
||||
step.echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from commit history"
|
||||
step.commonPipelineEnvironment.setChangeDocumentId(changeDocumentId)
|
||||
script.echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from commit history"
|
||||
script.commonPipelineEnvironment.setChangeDocumentId(changeDocumentId)
|
||||
|
||||
} catch(ChangeManagementException ex) {
|
||||
step.echo "[WARN] Cannot retrieve changeDocumentId from commit history: ${ex.getMessage()}."
|
||||
script.echo "[WARN] Cannot retrieve changeDocumentId from commit history: ${ex.getMessage()}."
|
||||
}
|
||||
|
||||
return changeDocumentId
|
||||
}
|
||||
|
||||
@NonCPS
|
||||
static BackendType getBackendTypeAndLogInfoIfCMIntegrationDisabled(def step, Map configuration) {
|
||||
static BackendType getBackendTypeAndLogInfoIfCMIntegrationDisabled(def script, Map configuration) {
|
||||
|
||||
BackendType backendType
|
||||
|
||||
try {
|
||||
backendType = configuration.changeManagement.type as BackendType
|
||||
} catch(IllegalArgumentException e) {
|
||||
step.error "Invalid backend type: '${configuration.changeManagement.type}'. " +
|
||||
script.error "Invalid backend type: '${configuration.changeManagement.type}'. " +
|
||||
"Valid values: [${BackendType.values().join(', ')}]. " +
|
||||
"Configuration: 'changeManagement/type'."
|
||||
}
|
||||
|
||||
if (backendType == BackendType.NONE) {
|
||||
step.echo "[INFO] Change management integration intentionally switched off. " +
|
||||
script.echo "[INFO] Change management integration intentionally switched off. " +
|
||||
"In order to enable it provide 'changeManagement/type with one of " +
|
||||
"[${BackendType.values().minus(BackendType.NONE).join(', ')}] and maintain " +
|
||||
"other required properties like 'endpoint', 'credentialsId'."
|
||||
|
@ -19,6 +19,7 @@ import util.Rules
|
||||
import static org.junit.Assert.assertThat
|
||||
|
||||
import static org.hamcrest.Matchers.hasItem
|
||||
import static org.hamcrest.Matchers.not
|
||||
import static org.hamcrest.Matchers.hasEntry
|
||||
import static org.hamcrest.Matchers.containsString
|
||||
|
||||
@ -126,6 +127,7 @@ class CloudFoundryDeployTest extends BasePiperTest {
|
||||
assertThat(jedr.dockerParams.dockerEnvVars, hasEntry('STATUS_CODE', "${200}"))
|
||||
assertThat(jscr.shell, hasItem(containsString('cf login -u "test_cf" -p \'********\' -a https://api.cf.eu10.hana.ondemand.com -o "testOrg" -s "testSpace"')))
|
||||
assertThat(jscr.shell, hasItem(containsString("cf push testAppName -f 'test.yml'")))
|
||||
assertThat(jscr.shell, hasItem(containsString("cf logout")))
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -175,6 +177,7 @@ class CloudFoundryDeployTest extends BasePiperTest {
|
||||
assertThat(jedr.dockerParams.dockerEnvVars, hasEntry('STATUS_CODE', "${200}"))
|
||||
assertThat(jscr.shell, hasItem(containsString('cf login -u "test_cf" -p \'********\' -a https://api.cf.eu10.hana.ondemand.com -o "testOrg" -s "testSpace"')))
|
||||
assertThat(jscr.shell, hasItem(containsString("cf push testAppName -f 'test.yml'")))
|
||||
assertThat(jscr.shell, hasItem(containsString("cf logout")))
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -198,6 +201,7 @@ class CloudFoundryDeployTest extends BasePiperTest {
|
||||
// asserts
|
||||
assertThat(jscr.shell, hasItem(containsString('cf login -u "test_cf" -p \'********\' -a https://api.cf.eu10.hana.ondemand.com -o "testOrg" -s "testSpace"')))
|
||||
assertThat(jscr.shell, hasItem(containsString("cf push -f 'test.yml'")))
|
||||
assertThat(jscr.shell, hasItem(containsString("cf logout")))
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -223,7 +227,7 @@ class CloudFoundryDeployTest extends BasePiperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCfNativeBlueGreen() {
|
||||
void testCfNativeBlueGreenDefaultDeleteOldInstance() {
|
||||
|
||||
jryr.registerYaml('test.yml', "applications: [[]]")
|
||||
|
||||
@ -244,8 +248,85 @@ class CloudFoundryDeployTest extends BasePiperTest {
|
||||
|
||||
assertThat(jscr.shell, hasItem(containsString('cf login -u "test_cf" -p \'********\' -a https://api.cf.eu10.hana.ondemand.com -o "testOrg" -s "testSpace"')))
|
||||
assertThat(jscr.shell, hasItem(containsString("cf blue-green-deploy testAppName --delete-old-apps -f 'test.yml'")))
|
||||
assertThat(jscr.shell, hasItem(containsString("cf logout")))
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCfNativeBlueGreenExplicitDeleteOldInstance() {
|
||||
|
||||
jryr.registerYaml('test.yml', "applications: [[]]")
|
||||
|
||||
jsr.step.cloudFoundryDeploy([
|
||||
script: nullScript,
|
||||
juStabUtils: utils,
|
||||
deployTool: 'cf_native',
|
||||
deployType: 'blue-green',
|
||||
keepOldInstance: false,
|
||||
cfOrg: 'testOrg',
|
||||
cfSpace: 'testSpace',
|
||||
cfCredentialsId: 'test_cfCredentialsId',
|
||||
cfAppName: 'testAppName',
|
||||
cfManifest: 'test.yml'
|
||||
])
|
||||
|
||||
assertThat(jedr.dockerParams, hasEntry('dockerImage', 's4sdk/docker-cf-cli'))
|
||||
assertThat(jedr.dockerParams, hasEntry('dockerWorkspace', '/home/piper'))
|
||||
|
||||
assertThat(jscr.shell, hasItem(containsString('cf login -u "test_cf" -p \'********\' -a https://api.cf.eu10.hana.ondemand.com -o "testOrg" -s "testSpace"')))
|
||||
assertThat(jscr.shell, hasItem(containsString("cf blue-green-deploy testAppName --delete-old-apps -f 'test.yml'")))
|
||||
assertThat(jscr.shell, not(hasItem(containsString("cf stop testAppName-old"))))
|
||||
assertThat(jscr.shell, hasItem(containsString("cf logout")))
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCfNativeBlueGreenKeepOldInstance() {
|
||||
|
||||
jryr.registerYaml('test.yml', "applications: [[]]")
|
||||
|
||||
jsr.step.cloudFoundryDeploy([
|
||||
script: nullScript,
|
||||
juStabUtils: utils,
|
||||
deployTool: 'cf_native',
|
||||
deployType: 'blue-green',
|
||||
keepOldInstance: true,
|
||||
cfOrg: 'testOrg',
|
||||
cfSpace: 'testSpace',
|
||||
cfCredentialsId: 'test_cfCredentialsId',
|
||||
cfAppName: 'testAppName',
|
||||
cfManifest: 'test.yml'
|
||||
])
|
||||
|
||||
assertThat(jedr.dockerParams, hasEntry('dockerImage', 's4sdk/docker-cf-cli'))
|
||||
assertThat(jedr.dockerParams, hasEntry('dockerWorkspace', '/home/piper'))
|
||||
|
||||
assertThat(jscr.shell, hasItem(containsString('cf login -u "test_cf" -p \'********\' -a https://api.cf.eu10.hana.ondemand.com -o "testOrg" -s "testSpace"')))
|
||||
assertThat(jscr.shell, hasItem(containsString("cf blue-green-deploy testAppName -f 'test.yml'")))
|
||||
assertThat(jscr.shell, hasItem(containsString("cf stop testAppName-old")))
|
||||
assertThat(jscr.shell, hasItem(containsString("cf logout")))
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCfNativeStandardShouldNotStopInstance() {
|
||||
|
||||
jryr.registerYaml('test.yml', "applications: [[]]")
|
||||
|
||||
jsr.step.cloudFoundryDeploy([
|
||||
script: nullScript,
|
||||
juStabUtils: utils,
|
||||
deployTool: 'cf_native',
|
||||
deployType: 'standard',
|
||||
keepOldInstance: true,
|
||||
cfOrg: 'testOrg',
|
||||
cfSpace: 'testSpace',
|
||||
cfCredentialsId: 'test_cfCredentialsId',
|
||||
cfAppName: 'testAppName',
|
||||
cfManifest: 'test.yml'
|
||||
])
|
||||
|
||||
assertThat(jscr.shell, not(hasItem(containsString("cf stop testAppName-old"))))
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCfNativeWithoutAppNameBlueGreen() {
|
||||
@ -285,5 +366,6 @@ class CloudFoundryDeployTest extends BasePiperTest {
|
||||
assertThat(jedr.dockerParams, hasEntry('dockerWorkspace', '/home/piper'))
|
||||
assertThat(jscr.shell, hasItem(containsString('cf login -u test_cf -p \'********\' -a https://api.cf.eu10.hana.ondemand.com -o "testOrg" -s "testSpace"')))
|
||||
assertThat(jscr.shell, hasItem(containsString('cf deploy target/test.mtar -f')))
|
||||
assertThat(jscr.shell, hasItem(containsString('cf logout')))
|
||||
}
|
||||
}
|
||||
|
@ -216,7 +216,6 @@ public class CommonStepsTest extends BasePiperTest{
|
||||
def stepsWithCallMethodsOtherThanVoid = []
|
||||
|
||||
def whitelist = [
|
||||
'transportRequestCreate',
|
||||
'durationMeasure',
|
||||
]
|
||||
|
||||
@ -238,7 +237,7 @@ public class CommonStepsTest extends BasePiperTest{
|
||||
private static getSteps() {
|
||||
List steps = []
|
||||
new File('vars').traverse(type: FileType.FILES, maxDepth: 0)
|
||||
{ if(it.getName().endsWith('.groovy')) steps << (it =~ /vars\/(.*)\.groovy/)[0][1] }
|
||||
{ if(it.getName().endsWith('.groovy')) steps << (it =~ /vars[\\\/](.*)\.groovy/)[0][1] }
|
||||
return steps
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import com.sap.piper.Utils
|
||||
import hudson.AbortException
|
||||
|
||||
import org.junit.rules.TemporaryFolder
|
||||
@ -6,6 +7,8 @@ import org.junit.BeforeClass
|
||||
import org.junit.ClassRule
|
||||
import org.junit.Ignore
|
||||
|
||||
import java.util.Map
|
||||
|
||||
import org.hamcrest.BaseMatcher
|
||||
import org.hamcrest.Description
|
||||
import org.jenkinsci.plugins.credentialsbinding.impl.CredentialNotFoundException
|
||||
@ -81,13 +84,25 @@ class NeoDeployTest extends BasePiperTest {
|
||||
@Test
|
||||
void straightForwardTestConfigViaConfigProperties() {
|
||||
|
||||
boolean buildStatusHasBeenSet = false
|
||||
boolean notifyOldConfigFrameworkUsed = false
|
||||
|
||||
nullScript.commonPipelineEnvironment.setConfigProperty('DEPLOY_HOST', 'test.deploy.host.com')
|
||||
nullScript.commonPipelineEnvironment.setConfigProperty('CI_DEPLOY_ACCOUNT', 'trialuser123')
|
||||
nullScript.commonPipelineEnvironment.configuration = [:]
|
||||
|
||||
nullScript.currentBuild = [setResult: {buildStatusHasBeenSet = true}]
|
||||
|
||||
def utils = new Utils() {
|
||||
void pushToSWA(Map parameters, Map config) {
|
||||
notifyOldConfigFrameworkUsed = parameters.stepParam4
|
||||
}
|
||||
}
|
||||
|
||||
jsr.step.neoDeploy(script: nullScript,
|
||||
archivePath: archiveName,
|
||||
neoCredentialsId: 'myCredentialsId'
|
||||
neoCredentialsId: 'myCredentialsId',
|
||||
utils: utils
|
||||
)
|
||||
|
||||
Assert.assertThat(jscr.shell,
|
||||
@ -98,14 +113,53 @@ class NeoDeployTest extends BasePiperTest {
|
||||
.hasSingleQuotedOption('user', 'anonymous')
|
||||
.hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*')
|
||||
.hasDoubleQuotedOption('source', '.*'))
|
||||
|
||||
assert !buildStatusHasBeenSet
|
||||
assert notifyOldConfigFrameworkUsed
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConfigViaConfigPropertiesSetsBuildToUnstable() {
|
||||
|
||||
def buildStatus = 'SUCCESS'
|
||||
|
||||
nullScript.commonPipelineEnvironment.setConfigProperty('DEPLOY_HOST', 'test.deploy.host.com')
|
||||
nullScript.commonPipelineEnvironment.setConfigProperty('CI_DEPLOY_ACCOUNT', 'trialuser123')
|
||||
nullScript.commonPipelineEnvironment.configuration = [:]
|
||||
|
||||
nullScript.currentBuild = [setResult: { r -> buildStatus = r}]
|
||||
|
||||
System.setProperty('com.sap.piper.featureFlag.buildUnstableWhenOldConfigFrameworkIsUsedByNeoDeploy',
|
||||
Boolean.TRUE.toString())
|
||||
|
||||
try {
|
||||
jsr.step.neoDeploy(script: nullScript,
|
||||
archivePath: archiveName,
|
||||
neoCredentialsId: 'myCredentialsId',
|
||||
utils: utils
|
||||
)
|
||||
} finally {
|
||||
System.clearProperty('com.sap.piper.featureFlag.buildUnstableWhenOldConfigFrameworkIsUsedByNeoDeploy')
|
||||
}
|
||||
|
||||
assert buildStatus == 'UNSTABLE'
|
||||
}
|
||||
|
||||
@Test
|
||||
void straightForwardTestConfigViaConfiguration() {
|
||||
|
||||
boolean notifyOldConfigFrameworkUsed = true
|
||||
|
||||
def utils = new Utils() {
|
||||
void pushToSWA(Map parameters, Map config) {
|
||||
notifyOldConfigFrameworkUsed = parameters.stepParam4
|
||||
}
|
||||
}
|
||||
|
||||
jsr.step.neoDeploy(script: nullScript,
|
||||
archivePath: archiveName,
|
||||
neoCredentialsId: 'myCredentialsId'
|
||||
neoCredentialsId: 'myCredentialsId',
|
||||
utils: utils,
|
||||
)
|
||||
|
||||
Assert.assertThat(jscr.shell,
|
||||
@ -116,6 +170,8 @@ class NeoDeployTest extends BasePiperTest {
|
||||
.hasSingleQuotedOption('user', 'anonymous')
|
||||
.hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*')
|
||||
.hasDoubleQuotedOption('source', '.*'))
|
||||
|
||||
assert !notifyOldConfigFrameworkUsed
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -68,7 +68,8 @@ class NewmanExecuteTest extends BasePiperTest {
|
||||
newmanGlobals: 'testGlobals'
|
||||
)
|
||||
// asserts
|
||||
assertThat(jscr.shell, hasItem('newman run testCollection --environment \'testEnvironment\' --globals \'testGlobals\' --reporters junit,html --reporter-junit-export target/newman/TEST-testCollection.xml --reporter-html-export target/newman/TEST-testCollection.html'))
|
||||
assertThat(jscr.shell, hasItem('npm install newman newman-reporter-html --global --quiet'))
|
||||
assertThat(jscr.shell, hasItem('newman run \'testCollection\' --environment \'testEnvironment\' --globals \'testGlobals\' --reporters junit,html --reporter-junit-export \'target/newman/TEST-testCollection.xml\' --reporter-html-export \'target/newman/TEST-testCollection.html\''))
|
||||
assertThat(jedr.dockerParams.dockerImage, is('node:8-stretch'))
|
||||
assertThat(jlr.log, containsString('[newmanExecute] Found files [testCollection]'))
|
||||
assertJobStatusSuccess()
|
||||
@ -102,7 +103,7 @@ class NewmanExecuteTest extends BasePiperTest {
|
||||
// asserts
|
||||
assertThat(jedr.dockerParams.dockerImage, is('testImage'))
|
||||
assertThat(gitMap.url, is('testRepo'))
|
||||
assertThat(jscr.shell, hasItem('newman run testCollection --environment \'testEnvironment\' --globals \'testGlobals\' --reporters junit,html --reporter-junit-export target/newman/TEST-testCollection.xml --reporter-html-export target/newman/TEST-testCollection.html --suppress-exit-code'))
|
||||
assertThat(jscr.shell, hasItem('newman run \'testCollection\' --environment \'testEnvironment\' --globals \'testGlobals\' --reporters junit,html --reporter-junit-export \'target/newman/TEST-testCollection.xml\' --reporter-html-export \'target/newman/TEST-testCollection.html\' --suppress-exit-code'))
|
||||
assertJobStatusSuccess()
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ class TestsPublishResultsTest extends BasePiperTest {
|
||||
assertTrue('JUnit options are empty', publisherStepOptions.junit != null)
|
||||
// ensure default patterns are set
|
||||
assertEquals('JUnit default pattern not set correct',
|
||||
'**/target/surefire-reports/*.xml', publisherStepOptions.junit.testResults)
|
||||
'**/TEST-*.xml', publisherStepOptions.junit.testResults)
|
||||
// ensure nothing else is published
|
||||
assertTrue('JaCoCo options are not empty', publisherStepOptions.jacoco == null)
|
||||
assertTrue('Cobertura options are not empty', publisherStepOptions.cobertura == null)
|
||||
|
@ -127,9 +127,9 @@ public class TransportRequestCreateTest extends BasePiperTest {
|
||||
}
|
||||
}
|
||||
|
||||
def transportId = jsr.step.transportRequestCreate(script: nullScript, changeDocumentId: '001', developmentSystemId: '001', cmUtils: cm)
|
||||
jsr.step.transportRequestCreate(script: nullScript, changeDocumentId: '001', developmentSystemId: '001', cmUtils: cm)
|
||||
|
||||
assert transportId == '001'
|
||||
assert nullScript.commonPipelineEnvironment.getTransportRequestId() == '001'
|
||||
assert result == [changeId: '001',
|
||||
developmentSystemId: '001',
|
||||
cmEndpoint: 'https://example.org/cm',
|
||||
@ -166,14 +166,14 @@ public class TransportRequestCreateTest extends BasePiperTest {
|
||||
}
|
||||
}
|
||||
|
||||
def transportId = jsr.step.transportRequestCreate(script: nullScript,
|
||||
transportType: 'W',
|
||||
targetSystem: 'XYZ',
|
||||
description: 'desc',
|
||||
changeManagement: [type: 'CTS'],
|
||||
cmUtils: cm)
|
||||
jsr.step.call(script: nullScript,
|
||||
transportType: 'W',
|
||||
targetSystem: 'XYZ',
|
||||
description: 'desc',
|
||||
changeManagement: [type: 'CTS'],
|
||||
cmUtils: cm)
|
||||
|
||||
assert transportId == '001'
|
||||
assert nullScript.commonPipelineEnvironment.getTransportRequestId() == '001'
|
||||
assert result == [transportType: 'W',
|
||||
targetSystemId: 'XYZ',
|
||||
description: 'desc',
|
||||
|
@ -108,6 +108,10 @@ public class TransportRequestReleaseTest extends BasePiperTest {
|
||||
@Test
|
||||
public void releaseTransportRequestSuccessTest() {
|
||||
|
||||
// Here we test only the case where the transportRequestId is
|
||||
// provided via parameters. The other cases are tested by
|
||||
// corresponding tests for StepHelpers#getTransportRequestId(./.)
|
||||
|
||||
jlr.expect("[INFO] Closing transport request '002' for change document '001'.")
|
||||
jlr.expect("[INFO] Transport Request '002' has been successfully closed.")
|
||||
|
||||
|
@ -194,6 +194,10 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
||||
@Test
|
||||
public void uploadFileToTransportRequestSOLMANSuccessTest() {
|
||||
|
||||
// Here we test only the case where the transportRequestId is
|
||||
// provided via parameters. The other cases are tested by
|
||||
// corresponding tests for StepHelpers#getTransportRequestId(./.)
|
||||
|
||||
jlr.expect("[INFO] Uploading file '/path' to transport request '002' of change document '001'.")
|
||||
jlr.expect("[INFO] File '/path' has been successfully uploaded to transport request '002' of change document '001'.")
|
||||
|
||||
|
@ -20,15 +20,18 @@ class StepHelpersTest extends BasePiperTest {
|
||||
to: 'HEAD',
|
||||
format: '%b'
|
||||
],
|
||||
changeDocumentLabel: "ChangeDocument:"
|
||||
changeDocumentLabel: "ChangeDocument:",
|
||||
transportRequestLabel: "TransportRequest:",
|
||||
]
|
||||
]
|
||||
|
||||
private Map getChangeDocumentIdReceivedParameters = [:]
|
||||
private Map getTransportRequestIdReceivedParameters = [:]
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
getChangeDocumentIdReceivedParameters.clear()
|
||||
getTransportRequestIdReceivedParameters.clear()
|
||||
}
|
||||
|
||||
JenkinsLoggingRule jlr = new JenkinsLoggingRule(this)
|
||||
@ -38,6 +41,20 @@ class StepHelpersTest extends BasePiperTest {
|
||||
.around(jlr)
|
||||
|
||||
private ChangeManagement cm = new ChangeManagement(nullScript) {
|
||||
|
||||
String getTransportRequestId(
|
||||
String from,
|
||||
String to,
|
||||
String label,
|
||||
String format
|
||||
) {
|
||||
getTransportRequestIdReceivedParameters['from'] = from
|
||||
getTransportRequestIdReceivedParameters['to'] = to
|
||||
getTransportRequestIdReceivedParameters['label'] = label
|
||||
getTransportRequestIdReceivedParameters['format'] = format
|
||||
return '097'
|
||||
}
|
||||
|
||||
String getChangeDocumentId(
|
||||
String from,
|
||||
String to,
|
||||
@ -53,6 +70,24 @@ class StepHelpersTest extends BasePiperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transportRequestIdViaCommitHistoryTest() {
|
||||
|
||||
def transportRequestId = StepHelpers.getTransportRequestId(cm, nullScript, params)
|
||||
|
||||
assert transportRequestId == '097'
|
||||
assert getTransportRequestIdReceivedParameters ==
|
||||
[
|
||||
from: 'HEAD~1',
|
||||
to: 'HEAD',
|
||||
label: 'TransportRequest:',
|
||||
format: '%b'
|
||||
]
|
||||
|
||||
// We cache the value. Otherwise we have to retrieve it each time from the
|
||||
// commit history.
|
||||
assert nullScript.commonPipelineEnvironment.getTransportRequestId() == '097'
|
||||
}
|
||||
|
||||
public void changeDocumentIdViaCommitHistoryTest() {
|
||||
|
||||
def changeDocumentId = StepHelpers.getChangeDocumentId(cm, nullScript, params)
|
||||
@ -69,10 +104,60 @@ class StepHelpersTest extends BasePiperTest {
|
||||
// We cache the value. Otherwise we have to retrieve it each time from the
|
||||
// commit history.
|
||||
assert nullScript.commonPipelineEnvironment.getChangeDocumentId() == '001'
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transportRequestIdViaCommonPipelineEnvironmentTest() {
|
||||
|
||||
nullScript.commonPipelineEnvironment.setTransportRequestId('098')
|
||||
def transportRequestId = StepHelpers.getTransportRequestId(cm, nullScript, params)
|
||||
|
||||
assert transportRequestId == '098'
|
||||
|
||||
// getTransportRequestId gets not called on ChangeManagement util class
|
||||
// in this case.
|
||||
assert getTransportRequestIdReceivedParameters == [:]
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transportRequestIdViaParametersTest() {
|
||||
|
||||
params << [transportRequestId: '099']
|
||||
|
||||
def transportRequestId = StepHelpers.getTransportRequestId(cm, nullScript, params)
|
||||
|
||||
assert transportRequestId == '099'
|
||||
|
||||
// In case we get the transport request id via parameters we do not cache it
|
||||
// Caller knows the transport request id anyway. So the caller can provide it with
|
||||
// each call.
|
||||
assert nullScript.commonPipelineEnvironment.getTransportRequestId() == null
|
||||
|
||||
// getTransportRequestId gets not called on ChangeManagement util class
|
||||
// in this case.
|
||||
assert getTransportRequestIdReceivedParameters == [:]
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transportRequestIdNotProvidedTest() {
|
||||
|
||||
jlr.expect('Cannot retrieve transportRequestId from commit history')
|
||||
|
||||
def cm = new ChangeManagement(nullScript) {
|
||||
String getTransportRequestId(
|
||||
String from,
|
||||
String to,
|
||||
String label,
|
||||
String format
|
||||
) {
|
||||
throw new ChangeManagementException('Cannot retrieve transport request id')
|
||||
}
|
||||
}
|
||||
|
||||
def transportRequestId = StepHelpers.getTransportRequestId(cm, nullScript, params)
|
||||
assert transportRequestId == null
|
||||
}
|
||||
|
||||
public void changeDocumentIdViaCommonPipelineEnvironmentTest() {
|
||||
|
||||
nullScript.commonPipelineEnvironment.setChangeDocumentId('002')
|
||||
@ -120,8 +205,8 @@ class StepHelpersTest extends BasePiperTest {
|
||||
}
|
||||
}
|
||||
|
||||
def transportRequestId = StepHelpers.getChangeDocumentId(cm, nullScript, params)
|
||||
def changeDocumentId = StepHelpers.getChangeDocumentId(cm, nullScript, params)
|
||||
|
||||
assert transportRequestId == null
|
||||
assert changeDocumentId == null
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import com.sap.piper.versioning.ArtifactVersioning
|
||||
import groovy.transform.Field
|
||||
import groovy.text.SimpleTemplateEngine
|
||||
|
||||
@Field String STEP_NAME = 'artifactSetVersion'
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
@Field Map CONFIG_KEY_COMPATIBILITY = [gitSshKeyCredentialsId: 'gitCredentialsId']
|
||||
|
||||
@Field Set GENERAL_CONFIG_KEYS = STEP_CONFIG_KEYS
|
||||
|
@ -6,7 +6,7 @@ import com.sap.piper.Utils
|
||||
import groovy.text.SimpleTemplateEngine
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field String STEP_NAME = 'batsExecuteTests'
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
|
||||
@Field Set GENERAL_CONFIG_KEYS = STEP_CONFIG_KEYS
|
||||
|
||||
@ -70,7 +70,7 @@ void call(Map parameters = [:]) {
|
||||
} finally {
|
||||
sh "cat 'TEST-${config.testPackage}.tap'"
|
||||
if (config.outputFormat == 'junit') {
|
||||
dockerExecute(dockerImage: config.dockerImage, dockerWorkspace: config.dockerWorkspace, stashContent: config.stashContent) {
|
||||
dockerExecute(script: script, dockerImage: config.dockerImage, dockerWorkspace: config.dockerWorkspace, stashContent: config.stashContent) {
|
||||
sh "npm install tap-xunit -g"
|
||||
sh "cat 'TEST-${config.testPackage}.tap' | tap-xunit --package='${config.testPackage}' > TEST-${config.testPackage}.xml"
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import com.sap.piper.cm.ChangeManagementException
|
||||
import static com.sap.piper.cm.StepHelpers.getChangeDocumentId
|
||||
import static com.sap.piper.cm.StepHelpers.getBackendTypeAndLogInfoIfCMIntegrationDisabled
|
||||
|
||||
@Field def STEP_NAME = 'checkChangeInDevelopment'
|
||||
@Field def STEP_NAME = getClass().getName()
|
||||
|
||||
@Field Set GENERAL_CONFIG_KEYS = STEP_CONFIG_KEYS
|
||||
|
||||
@ -97,7 +97,7 @@ void call(parameters = [:]) {
|
||||
new Utils().pushToSWA([step: STEP_NAME,
|
||||
stepParam1: parameters?.script == null], configuration)
|
||||
|
||||
def changeId = getChangeDocumentId(cm, this, configuration)
|
||||
def changeId = getChangeDocumentId(cm, script, configuration)
|
||||
|
||||
configuration = configHelper.mixin([changeDocumentId: changeId?.trim() ?: null], ['changeDocumentId'] as Set)
|
||||
|
||||
|
@ -8,7 +8,7 @@ import com.sap.piper.Utils
|
||||
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field def STEP_NAME = 'checksPublishResults'
|
||||
@Field def STEP_NAME = getClass().getName()
|
||||
|
||||
@Field Set TOOLS = [
|
||||
'aggregation', 'tasks', 'pmd', 'cpd', 'findbugs', 'checkstyle', 'eslint', 'pylint'
|
||||
|
@ -6,7 +6,7 @@ import com.sap.piper.CfManifestUtils
|
||||
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field String STEP_NAME = 'cloudFoundryDeploy'
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
|
||||
@Field Set GENERAL_CONFIG_KEYS = STEP_CONFIG_KEYS
|
||||
|
||||
@ -15,6 +15,7 @@ import groovy.transform.Field
|
||||
'deployUser',
|
||||
'deployTool',
|
||||
'deployType',
|
||||
'keepOldInstance',
|
||||
'dockerImage',
|
||||
'dockerWorkspace',
|
||||
'mtaDeployParameters',
|
||||
@ -57,7 +58,10 @@ void call(Map parameters = [:]) {
|
||||
|
||||
echo "[${STEP_NAME}] General parameters: deployTool=${config.deployTool}, deployType=${config.deployType}, cfApiEndpoint=${config.cloudFoundry.apiEndpoint}, cfOrg=${config.cloudFoundry.org}, cfSpace=${config.cloudFoundry.space}, cfCredentialsId=${config.cloudFoundry.credentialsId}, deployUser=${config.deployUser}"
|
||||
|
||||
config.stashContent = utils.unstashAll(config.stashContent)
|
||||
//make sure that all relevant descriptors, are available in workspace
|
||||
utils.unstashAll(config.stashContent)
|
||||
//make sure that for further execution whole workspace, e.g. also downloaded artifacts are considered
|
||||
config.stashContent = []
|
||||
|
||||
if (config.deployTool == 'mtaDeployPlugin') {
|
||||
// set default mtar path
|
||||
@ -65,7 +69,7 @@ void call(Map parameters = [:]) {
|
||||
.addIfEmpty('mtaPath', config.mtaPath?:findMtar())
|
||||
.use()
|
||||
|
||||
dockerExecute(dockerImage: config.dockerImage, dockerWorkspace: config.dockerWorkspace, stashContent: config.stashContent) {
|
||||
dockerExecute(script: script, dockerImage: config.dockerImage, dockerWorkspace: config.dockerWorkspace, stashContent: config.stashContent) {
|
||||
deployMta(config)
|
||||
}
|
||||
return
|
||||
@ -84,6 +88,7 @@ void call(Map parameters = [:]) {
|
||||
echo "[${STEP_NAME}] CF native deployment (${config.deployType}) with cfAppName=${config.cloudFoundry.appName}, cfManifest=${config.cloudFoundry.manifest}, smokeTestScript=${config.smokeTestScript}"
|
||||
|
||||
dockerExecute (
|
||||
script: script,
|
||||
dockerImage: config.dockerImage,
|
||||
dockerWorkspace: config.dockerWorkspace,
|
||||
stashContent: config.stashContent,
|
||||
@ -116,14 +121,16 @@ def deployCfNative (config) {
|
||||
passwordVariable: 'password',
|
||||
usernameVariable: 'username'
|
||||
)]) {
|
||||
def deployCommand = 'push'
|
||||
def deployCommand = selectCfDeployCommandForDeployType(config)
|
||||
|
||||
if (config.deployType == 'blue-green') {
|
||||
deployCommand = 'blue-green-deploy'
|
||||
handleLegacyCfManifest(config)
|
||||
} else {
|
||||
config.smokeTest = ''
|
||||
}
|
||||
|
||||
def blueGreenDeployOptions = deleteOptionIfRequired(config)
|
||||
|
||||
// check if appName is available
|
||||
if (config.cloudFoundry.appName == null || config.cloudFoundry.appName == '') {
|
||||
if (config.deployType == 'blue-green') {
|
||||
@ -144,11 +151,38 @@ def deployCfNative (config) {
|
||||
export HOME=${config.dockerWorkspace}
|
||||
cf login -u \"${username}\" -p '${password}' -a ${config.cloudFoundry.apiEndpoint} -o \"${config.cloudFoundry.org}\" -s \"${config.cloudFoundry.space}\"
|
||||
cf plugins
|
||||
cf ${deployCommand} ${config.cloudFoundry.appName?:''} ${config.deployType == 'blue-green'?'--delete-old-apps':''} -f '${config.cloudFoundry.manifest}' ${config.smokeTest}"""
|
||||
cf ${deployCommand} ${config.cloudFoundry.appName ?: ''} ${blueGreenDeployOptions} -f '${config.cloudFoundry.manifest}' ${config.smokeTest}
|
||||
${stopOldAppIfRequired(config)}
|
||||
"""
|
||||
sh "cf logout"
|
||||
}
|
||||
}
|
||||
|
||||
private String selectCfDeployCommandForDeployType(Map config) {
|
||||
if (config.deployType == 'blue-green') {
|
||||
return 'blue-green-deploy'
|
||||
} else {
|
||||
return 'push'
|
||||
}
|
||||
}
|
||||
|
||||
private String deleteOptionIfRequired(Map config) {
|
||||
boolean deleteOldInstance = !config.keepOldInstance
|
||||
if (deleteOldInstance && config.deployType == 'blue-green') {
|
||||
return '--delete-old-apps'
|
||||
} else {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
private String stopOldAppIfRequired(Map config) {
|
||||
if (config.keepOldInstance && config.deployType == 'blue-green') {
|
||||
return "cf stop ${config.cloudFoundry.appName}-old"
|
||||
} else {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
def deployMta (config) {
|
||||
if (config.mtaExtensionDescriptor == null) config.mtaExtensionDescriptor = ''
|
||||
if (!config.mtaExtensionDescriptor.isEmpty() && !config.mtaExtensionDescriptor.startsWith('-e ')) config.mtaExtensionDescriptor = "-e ${config.mtaExtensionDescriptor}"
|
||||
|
@ -30,6 +30,7 @@ class commonPipelineEnvironment implements Serializable {
|
||||
|
||||
String mtarFilePath
|
||||
|
||||
String transportRequestId
|
||||
String changeDocumentId
|
||||
|
||||
def reset() {
|
||||
@ -52,6 +53,7 @@ class commonPipelineEnvironment implements Serializable {
|
||||
|
||||
mtarFilePath = null
|
||||
|
||||
transportRequestId = null
|
||||
changeDocumentId = null
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import com.sap.piper.k8s.ContainerMap
|
||||
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field def STEP_NAME = 'dockerExecute'
|
||||
@Field def STEP_NAME = getClass().getName()
|
||||
@Field def PLUGIN_ID_DOCKER_WORKFLOW = 'docker-workflow'
|
||||
|
||||
@Field Set GENERAL_CONFIG_KEYS = ['jenkinsKubernetes']
|
||||
|
@ -7,7 +7,7 @@ import com.sap.piper.k8s.SystemEnv
|
||||
import groovy.transform.Field
|
||||
import hudson.AbortException
|
||||
|
||||
@Field def STEP_NAME = 'dockerExecuteOnKubernetes'
|
||||
@Field def STEP_NAME = getClass().getName()
|
||||
@Field def PLUGIN_ID_KUBERNETES = 'kubernetes'
|
||||
@Field Set GENERAL_CONFIG_KEYS = ['jenkinsKubernetes']
|
||||
@Field Set PARAMETER_KEYS = [
|
||||
|
@ -1,7 +1,7 @@
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field STEP_NAME = 'durationMeasure'
|
||||
@Field STEP_NAME = getClass().getName()
|
||||
|
||||
def call(Map parameters = [:], body) {
|
||||
|
||||
|
@ -6,7 +6,7 @@ import com.sap.piper.GitUtils
|
||||
import groovy.text.SimpleTemplateEngine
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field String STEP_NAME = 'gaugeExecuteTests'
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
@Field Set STEP_CONFIG_KEYS = [
|
||||
'buildTool',
|
||||
'dockerEnvVars',
|
||||
|
@ -5,7 +5,7 @@ import com.sap.piper.ConfigurationHelper
|
||||
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field String STEP_NAME = 'githubPublishRelease'
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
@Field Set GENERAL_CONFIG_KEYS = ['githubApiUrl', 'githubTokenCredentialsId', 'githubServerUrl']
|
||||
@Field Set STEP_CONFIG_KEYS = [
|
||||
'addClosedIssues',
|
||||
|
@ -1,7 +1,7 @@
|
||||
import groovy.text.SimpleTemplateEngine
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field STEP_NAME = 'handlePipelineStepErrors'
|
||||
@Field STEP_NAME = getClass().getName()
|
||||
|
||||
void call(Map parameters = [:], body) {
|
||||
def stepParameters = parameters.stepParameters //mandatory
|
||||
|
@ -4,7 +4,7 @@ import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.Utils
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field String STEP_NAME = 'healthExecuteCheck'
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
|
||||
@Field Set GENERAL_CONFIG_KEYS = STEP_CONFIG_KEYS
|
||||
|
||||
|
@ -8,7 +8,7 @@ import com.sap.piper.Utils
|
||||
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field def STEP_NAME = 'influxWriteData'
|
||||
@Field def STEP_NAME = getClass().getName()
|
||||
|
||||
@Field Set GENERAL_CONFIG_KEYS = []
|
||||
@Field Set STEP_CONFIG_KEYS = [
|
||||
|
@ -7,7 +7,7 @@ import com.sap.piper.Utils
|
||||
import groovy.text.SimpleTemplateEngine
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field String STEP_NAME = 'karmaExecuteTests'
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
@Field Set GENERAL_CONFIG_KEYS = [
|
||||
/** port mappings required for containers. This will only take effect inside a Kubernetes pod, format [[containerPort: 1111, hostPort: 1111]] */
|
||||
'containerPortMappings',
|
||||
|
@ -5,7 +5,7 @@ import com.sap.piper.Utils
|
||||
import groovy.text.SimpleTemplateEngine
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field String STEP_NAME = 'mailSendNotification'
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
@Field Set GENERAL_CONFIG_KEYS = ['gitSshKeyCredentialsId']
|
||||
@Field Set STEP_CONFIG_KEYS = [
|
||||
'projectName',
|
||||
@ -134,42 +134,47 @@ def getCulpritCommitters(config, currentBuild) {
|
||||
}
|
||||
|
||||
def getCulprits(config, branch, numberOfCommits) {
|
||||
if (branch?.startsWith('PR-')) {
|
||||
//special GitHub Pull Request handling
|
||||
deleteDir()
|
||||
sshagent(
|
||||
credentials: [config.gitSshKeyCredentialsId],
|
||||
ignoreMissing: true
|
||||
) {
|
||||
def pullRequestID = branch.replaceAll('PR-', '')
|
||||
def localBranchName = "pr" + pullRequestID;
|
||||
sh """git init
|
||||
git fetch ${config.gitUrl} pull/${pullRequestID}/head:${localBranchName} > /dev/null 2>&1
|
||||
git checkout -f ${localBranchName} > /dev/null 2>&1
|
||||
"""
|
||||
}
|
||||
} else {
|
||||
//standard git/GitHub handling
|
||||
if (config.gitCommitId) {
|
||||
try {
|
||||
if (branch?.startsWith('PR-')) {
|
||||
//special GitHub Pull Request handling
|
||||
deleteDir()
|
||||
sshagent(
|
||||
credentials: [config.gitSshKeyCredentialsId],
|
||||
ignoreMissing: true
|
||||
) {
|
||||
sh """git clone ${config.gitUrl} .
|
||||
git checkout ${config.gitCommitId} > /dev/null 2>&1"""
|
||||
def pullRequestID = branch.replaceAll('PR-', '')
|
||||
def localBranchName = "pr" + pullRequestID;
|
||||
sh """git init
|
||||
git fetch ${config.gitUrl} pull/${pullRequestID}/head:${localBranchName} > /dev/null 2>&1
|
||||
git checkout -f ${localBranchName} > /dev/null 2>&1
|
||||
"""
|
||||
}
|
||||
} else {
|
||||
def retCode = sh(returnStatus: true, script: 'git log > /dev/null 2>&1')
|
||||
if (retCode != 0) {
|
||||
echo "[${STEP_NAME}] No git context available to retrieve culprits"
|
||||
return ''
|
||||
//standard git/GitHub handling
|
||||
if (config.gitCommitId) {
|
||||
deleteDir()
|
||||
sshagent(
|
||||
credentials: [config.gitSshKeyCredentialsId],
|
||||
ignoreMissing: true
|
||||
) {
|
||||
sh """git clone ${config.gitUrl} .
|
||||
git checkout ${config.gitCommitId} > /dev/null 2>&1"""
|
||||
}
|
||||
} else {
|
||||
def retCode = sh(returnStatus: true, script: 'git log > /dev/null 2>&1')
|
||||
if (retCode != 0) {
|
||||
echo "[${STEP_NAME}] No git context available to retrieve culprits"
|
||||
return ''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def recipients = sh(returnStdout: true, script: "git log -${numberOfCommits} --pretty=format:'%ae %ce'")
|
||||
return getDistinctRecipients(recipients)
|
||||
def recipients = sh(returnStdout: true, script: "git log -${numberOfCommits} --pretty=format:'%ae %ce'")
|
||||
return getDistinctRecipients(recipients)
|
||||
} catch(err) {
|
||||
echo "[${STEP_NAME}] Culprit retrieval from git failed with '${err.getMessage()}'. Please make sure to configure gitSshKeyCredentialsId. So far, only fixed list of recipients is used."
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
def getDistinctRecipients(recipients){
|
||||
|
@ -5,7 +5,7 @@ import com.sap.piper.Utils
|
||||
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field def STEP_NAME = 'mavenExecute'
|
||||
@Field def STEP_NAME = getClass().getName()
|
||||
|
||||
@Field Set GENERAL_CONFIG_KEYS = []
|
||||
@Field Set STEP_CONFIG_KEYS = [
|
||||
|
@ -8,7 +8,7 @@ import com.sap.piper.tools.ToolDescriptor
|
||||
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field def STEP_NAME = 'mtaBuild'
|
||||
@Field def STEP_NAME = getClass().getName()
|
||||
|
||||
@Field Set GENERAL_CONFIG_KEYS = []
|
||||
@Field Set STEP_CONFIG_KEYS = [
|
||||
@ -77,13 +77,14 @@ void call(Map parameters = [:]) {
|
||||
if (configuration.extension) mtaCall += " --extension=$configuration.extension"
|
||||
mtaCall += ' build'
|
||||
|
||||
echo "[INFO] Executing mta build call: '${mtaCall}'."
|
||||
|
||||
sh """#!/bin/bash
|
||||
export PATH=./node_modules/.bin:${PATH}
|
||||
$mtaCall
|
||||
"""
|
||||
|
||||
def mtarFilePath = "${mtarFileName}"
|
||||
script?.commonPipelineEnvironment?.setMtarFilePath(mtarFilePath)
|
||||
script?.commonPipelineEnvironment?.setMtarFilePath(mtarFileName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import com.sap.piper.tools.ToolDescriptor
|
||||
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field String STEP_NAME = 'neoDeploy'
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
@Field Set GENERAL_CONFIG_KEYS = []
|
||||
@Field Set STEP_CONFIG_KEYS = [
|
||||
'account',
|
||||
@ -36,7 +36,7 @@ void call(parameters = [:]) {
|
||||
|
||||
def script = checkScript(this, parameters) ?: this
|
||||
|
||||
def utils = new Utils()
|
||||
def utils = parameters.utils ?: new Utils()
|
||||
|
||||
prepareDefaultValues script: script
|
||||
|
||||
@ -72,6 +72,23 @@ void call(parameters = [:]) {
|
||||
echo "[WARNING][${STEP_NAME}] Deprecated parameter 'neoCredentialsId' from old configuration framework is used. This will not work anymore in future versions."
|
||||
parameters.put('neoCredentialsId', credId)
|
||||
}
|
||||
|
||||
if(! stepCompatibilityConfiguration.isEmpty()) {
|
||||
echo "[WARNING][$STEP_NAME] You are using a deprecated configuration framework. This will be removed in " +
|
||||
'futureVersions.\nAdd snippet below to \'./pipeline/config.yml\' and remove ' +
|
||||
'file \'.pipeline/configuration.properties\'.\n' +
|
||||
"""|steps:
|
||||
| neoDeploy:
|
||||
| host: ${stepCompatibilityConfiguration.get('host', '<Add host here>')}
|
||||
| account: ${stepCompatibilityConfiguration.get('account', '<Add account here>')}
|
||||
""".stripMargin()
|
||||
|
||||
if(Boolean.getBoolean('com.sap.piper.featureFlag.buildUnstableWhenOldConfigFrameworkIsUsedByNeoDeploy')) {
|
||||
script.currentBuild.setResult('UNSTABLE')
|
||||
echo "[WARNING][$STEP_NAME] Build has been set to unstable since old config framework is used."
|
||||
}
|
||||
}
|
||||
|
||||
// Backward compatibility end
|
||||
|
||||
// load default & individual configuration
|
||||
@ -89,7 +106,8 @@ void call(parameters = [:]) {
|
||||
step: STEP_NAME,
|
||||
stepParam1: configuration.deployMode == 'mta'?'mta':'war', // ['mta', 'warParams', 'warPropertiesFile']
|
||||
stepParam2: configuration.warAction == 'rolling-update'?'blue-green':'standard', // ['deploy', 'deploy-mta', 'rolling-update']
|
||||
stepParam3: parameters?.script == null
|
||||
stepParam3: parameters?.script == null,
|
||||
stepParam4: ! stepCompatibilityConfiguration.isEmpty(),
|
||||
], configuration)
|
||||
|
||||
def archivePath = configuration.archivePath
|
||||
|
@ -6,7 +6,7 @@ import com.sap.piper.Utils
|
||||
import groovy.text.SimpleTemplateEngine
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field String STEP_NAME = 'newmanExecute'
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
|
||||
@Field Set GENERAL_CONFIG_KEYS = STEP_CONFIG_KEYS
|
||||
|
||||
@ -18,6 +18,7 @@ import groovy.transform.Field
|
||||
'newmanCollection',
|
||||
'newmanEnvironment',
|
||||
'newmanGlobals',
|
||||
'newmanInstallCommand',
|
||||
'newmanRunCommand',
|
||||
'stashContent',
|
||||
'testRepository'
|
||||
@ -56,10 +57,11 @@ void call(Map parameters = [:]) {
|
||||
}
|
||||
|
||||
dockerExecute(
|
||||
script: script,
|
||||
dockerImage: config.dockerImage,
|
||||
stashContent: config.stashContent
|
||||
) {
|
||||
sh 'npm install newman --global --quiet'
|
||||
sh "${config.newmanInstallCommand}"
|
||||
for(String collection : collectionList){
|
||||
def collectionDisplayName = collection.toString().replace(File.separatorChar,(char)'_').tokenize('.').first()
|
||||
// resolve templates
|
||||
|
@ -3,7 +3,7 @@ import com.sap.piper.Utils
|
||||
import groovy.transform.Field
|
||||
|
||||
|
||||
@Field STEP_NAME = 'pipelineExecute'
|
||||
@Field STEP_NAME = getClass().getName()
|
||||
|
||||
|
||||
/**
|
||||
|
@ -4,7 +4,7 @@ import com.sap.piper.JenkinsUtils
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field String STEP_NAME = 'pipelineRestartSteps'
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
@Field Set STEP_CONFIG_KEYS = [
|
||||
'sendMail',
|
||||
'timeoutInSeconds'
|
||||
|
@ -1,6 +1,6 @@
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field STEP_NAME = 'pipelineStashFiles'
|
||||
@Field STEP_NAME = getClass().getName()
|
||||
|
||||
void call(Map parameters = [:], body) {
|
||||
handlePipelineStepErrors (stepName: 'pipelineStashFiles', stepParameters: parameters) {
|
||||
|
@ -4,7 +4,7 @@ import com.sap.piper.Utils
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field String STEP_NAME = 'pipelineStashFilesAfterBuild'
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
@Field Set STEP_CONFIG_KEYS = ['runCheckmarx', 'stashIncludes', 'stashExcludes']
|
||||
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
|
||||
|
||||
@ -48,14 +48,14 @@ void call(Map parameters = [:]) {
|
||||
|
||||
utils.stashWithMessage(
|
||||
'classFiles',
|
||||
'[${STEP_NAME}] Failed to stash class files.',
|
||||
"[${STEP_NAME}] Failed to stash class files.",
|
||||
config.stashIncludes.classFiles,
|
||||
config.stashExcludes.classFiles
|
||||
)
|
||||
|
||||
utils.stashWithMessage(
|
||||
'sonar',
|
||||
'[${STEP_NAME}] Failed to stash sonar files.',
|
||||
"[${STEP_NAME}] Failed to stash sonar files.",
|
||||
config.stashIncludes.sonar,
|
||||
config.stashExcludes.sonar
|
||||
)
|
||||
|
@ -4,7 +4,7 @@ import com.sap.piper.Utils
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field String STEP_NAME = 'pipelineStashFilesBeforeBuild'
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
@Field Set STEP_CONFIG_KEYS = ['runOpaTests', 'stashIncludes', 'stashExcludes']
|
||||
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
|
||||
|
||||
@ -48,7 +48,7 @@ void call(Map parameters = [:]) {
|
||||
//store deployment descriptor files depending on technology, e.g. *.mtaext.yml
|
||||
utils.stashWithMessage(
|
||||
'deployDescriptor',
|
||||
'[${STEP_NAME}] no deployment descriptor files provided: ',
|
||||
"[${STEP_NAME}] no deployment descriptor files provided: ",
|
||||
config.stashIncludes.deployDescriptor,
|
||||
config.stashExcludes.deployDescriptor
|
||||
)
|
||||
@ -58,34 +58,34 @@ void call(Map parameters = [:]) {
|
||||
sh "chmod -R u+w gitmetadata"
|
||||
utils.stashWithMessage(
|
||||
'git',
|
||||
'[${STEP_NAME}] no git repo files detected: ',
|
||||
"[${STEP_NAME}] no git repo files detected: ",
|
||||
config.stashIncludes.git,
|
||||
config.stashExcludes.git
|
||||
)
|
||||
//store nsp & retire exclusion file for future use
|
||||
utils.stashWithMessage(
|
||||
'opensourceConfiguration',
|
||||
'[${STEP_NAME}] no opensourceConfiguration files provided: ',
|
||||
"[${STEP_NAME}] no opensourceConfiguration files provided: ",
|
||||
config.stashIncludes.get('opensourceConfiguration'),
|
||||
config.stashExcludes.get('opensourceConfiguration')
|
||||
)
|
||||
//store pipeline configuration including additional groovy test scripts for future use
|
||||
utils.stashWithMessage(
|
||||
'pipelineConfigAndTests',
|
||||
'[${STEP_NAME}] no pipeline configuration and test files found: ',
|
||||
"[${STEP_NAME}] no pipeline configuration and test files found: ",
|
||||
config.stashIncludes.pipelineConfigAndTests,
|
||||
config.stashExcludes.pipelineConfigAndTests
|
||||
)
|
||||
utils.stashWithMessage(
|
||||
'securityDescriptor',
|
||||
'[${STEP_NAME}] no security descriptor found: ',
|
||||
"[${STEP_NAME}] no security descriptor found: ",
|
||||
config.stashIncludes.securityDescriptor,
|
||||
config.stashExcludes.securityDescriptor
|
||||
)
|
||||
//store files required for tests, e.g. Gauge, SUT, ...
|
||||
utils.stashWithMessage(
|
||||
'tests',
|
||||
'[${STEP_NAME}] no files for tests provided: ',
|
||||
"[${STEP_NAME}] no files for tests provided: ",
|
||||
config.stashIncludes.tests,
|
||||
config.stashExcludes.tests
|
||||
)
|
||||
|
@ -3,7 +3,7 @@ import com.sap.piper.MapUtils
|
||||
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field STEP_NAME = 'prepareDefaultValues'
|
||||
@Field STEP_NAME = getClass().getName()
|
||||
|
||||
void call(Map parameters = [:]) {
|
||||
handlePipelineStepErrors (stepName: 'prepareDefaultValues', stepParameters: parameters) {
|
||||
|
@ -7,7 +7,7 @@ import com.sap.piper.k8s.ContainerMap
|
||||
import groovy.transform.Field
|
||||
import groovy.text.SimpleTemplateEngine
|
||||
|
||||
@Field String STEP_NAME = 'seleniumExecuteTests'
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
|
||||
@Field GENERAL_CONFIG_KEYS = STEP_CONFIG_KEYS
|
||||
|
||||
|
@ -4,7 +4,7 @@ import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.Utils
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field String STEP_NAME = 'setupCommonPipelineEnvironment'
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
@Field Set GENERAL_CONFIG_KEYS = ['collectTelemetryData']
|
||||
|
||||
void call(Map parameters = [:]) {
|
||||
|
@ -6,7 +6,7 @@ import com.sap.piper.mta.MtaMultiplexer
|
||||
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field def STEP_NAME = 'snykExecute'
|
||||
@Field def STEP_NAME = getClass().getName()
|
||||
|
||||
@Field Set GENERAL_CONFIG_KEYS = ['snykCredentialsId']
|
||||
@Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus([
|
||||
@ -62,6 +62,7 @@ void call(Map parameters = [:]) {
|
||||
variable: 'token'
|
||||
)]) {
|
||||
dockerExecute(
|
||||
script: script,
|
||||
dockerImage: config.dockerImage,
|
||||
stashContent: config.stashContent,
|
||||
dockerEnvVars: ['SNYK_TOKEN': token]
|
||||
|
@ -11,7 +11,7 @@ import groovy.transform.Field
|
||||
'junit','jacoco','cobertura','jmeter'
|
||||
]
|
||||
|
||||
@Field def STEP_NAME = 'testsPublishResults'
|
||||
@Field def STEP_NAME = getClass().getName()
|
||||
@Field Set GENERAL_CONFIG_KEYS = TOOLS
|
||||
@Field Set STEP_CONFIG_KEYS = TOOLS
|
||||
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
|
||||
|
@ -8,7 +8,7 @@ import groovy.transform.Field
|
||||
|
||||
import hudson.AbortException
|
||||
|
||||
@Field STEP_NAME = 'toolValidate'
|
||||
@Field STEP_NAME = getClass().getName()
|
||||
|
||||
void call(Map parameters = [:]) {
|
||||
|
||||
|
@ -13,7 +13,7 @@ import static com.sap.piper.cm.StepHelpers.getBackendTypeAndLogInfoIfCMIntegrati
|
||||
import static com.sap.piper.cm.StepHelpers.getChangeDocumentId
|
||||
import hudson.AbortException
|
||||
|
||||
@Field def STEP_NAME = 'transportRequestCreate'
|
||||
@Field def STEP_NAME = getClass().getName()
|
||||
|
||||
@Field GENERAL_CONFIG_KEYS = STEP_CONFIG_KEYS
|
||||
|
||||
@ -27,7 +27,7 @@ import hudson.AbortException
|
||||
|
||||
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS.plus(['changeDocumentId'])
|
||||
|
||||
def call(parameters = [:]) {
|
||||
void call(parameters = [:]) {
|
||||
|
||||
def transportRequestId
|
||||
|
||||
@ -68,7 +68,7 @@ def call(parameters = [:]) {
|
||||
|
||||
if(backendType == BackendType.SOLMAN) {
|
||||
|
||||
changeDocumentId = getChangeDocumentId(cm, this, configuration)
|
||||
changeDocumentId = getChangeDocumentId(cm, script, configuration)
|
||||
|
||||
configHelper.mixin([changeDocumentId: changeDocumentId?.trim() ?: null], ['changeDocumentId'] as Set)
|
||||
.withMandatoryProperty('developmentSystemId')
|
||||
@ -110,7 +110,6 @@ def call(parameters = [:]) {
|
||||
|
||||
|
||||
echo "[INFO] Transport Request '$transportRequestId' has been successfully created."
|
||||
script.commonPipelineEnvironment.setTransportRequestId(transportRequestId)
|
||||
}
|
||||
|
||||
return transportRequestId
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import static com.sap.piper.cm.StepHelpers.getTransportRequestId
|
||||
import static com.sap.piper.cm.StepHelpers.getChangeDocumentId
|
||||
import static com.sap.piper.cm.StepHelpers.getBackendTypeAndLogInfoIfCMIntegrationDisabled
|
||||
|
||||
@Field def STEP_NAME = 'transportRequestRelease'
|
||||
@Field def STEP_NAME = getClass().getName()
|
||||
|
||||
@Field Set GENERAL_CONFIG_KEYS = STEP_CONFIG_KEYS
|
||||
|
||||
@ -62,11 +62,11 @@ void call(parameters = [:]) {
|
||||
stepParam1: parameters?.script == null], configuration)
|
||||
|
||||
def changeDocumentId = null
|
||||
def transportRequestId = getTransportRequestId(cm, this, configuration)
|
||||
def transportRequestId = getTransportRequestId(cm, script, configuration)
|
||||
|
||||
if(backendType == BackendType.SOLMAN) {
|
||||
|
||||
changeDocumentId = getChangeDocumentId(cm, this, configuration)
|
||||
changeDocumentId = getChangeDocumentId(cm, script, configuration)
|
||||
|
||||
configHelper.mixin([changeDocumentId: changeDocumentId?.trim() ?: null], ['changeDocumentId'] as Set)
|
||||
.withMandatoryProperty('changeDocumentId',
|
||||
|
@ -14,7 +14,7 @@ import static com.sap.piper.cm.StepHelpers.getTransportRequestId
|
||||
import static com.sap.piper.cm.StepHelpers.getChangeDocumentId
|
||||
import static com.sap.piper.cm.StepHelpers.getBackendTypeAndLogInfoIfCMIntegrationDisabled
|
||||
|
||||
@Field def STEP_NAME = 'transportRequestUploadFile'
|
||||
@Field def STEP_NAME = getClass().getName()
|
||||
|
||||
@Field Set GENERAL_CONFIG_KEYS = [
|
||||
'changeManagement'
|
||||
@ -68,10 +68,10 @@ void call(parameters = [:]) {
|
||||
def changeDocumentId = null
|
||||
|
||||
if(backendType == BackendType.SOLMAN) {
|
||||
changeDocumentId = getChangeDocumentId(cm, this, configuration)
|
||||
changeDocumentId = getChangeDocumentId(cm, script, configuration)
|
||||
}
|
||||
|
||||
def transportRequestId = getTransportRequestId(cm, this, configuration)
|
||||
def transportRequestId = getTransportRequestId(cm, script, configuration)
|
||||
|
||||
configHelper
|
||||
.mixin([changeDocumentId: changeDocumentId?.trim() ?: null,
|
||||
|
Loading…
x
Reference in New Issue
Block a user