mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-11-24 08:32:32 +02:00
Config & Documentation ATC System Configuration Steps/Stage (#3552)
This commit is contained in:
parent
d7a13aa5d0
commit
dbb8173be8
@ -11,7 +11,7 @@ You can have a look at different pipeline configurations in our [SAP-samples rep
|
||||
| [Initial Checks](stages/initialChecks.md) | [abapAddonAssemblyKitCheckPV](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitCheckPV/), [abapAddonAssemblyKitCheckCVs](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitCheckCVs/), [abapAddonAssemblyKitReserveNextPackages](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitReserveNextPackages/),|
|
||||
| [Prepare System](stages/prepareSystem.md) | [abapEnvironmentCreateSystem](https://sap.github.io/jenkins-library/steps/abapEnvironmentCreateSystem/), [cloudFoundryCreateServiceKey](https://sap.github.io/jenkins-library/steps/cloudFoundryCreateServiceKey/)|
|
||||
| [Clone Repositories](stages/cloneRepositories.md) | [abapEnvironmentPullGitRepo](https://sap.github.io/jenkins-library/steps/abapEnvironmentPullGitRepo/), [abapEnvironmentCloneGitRepo](https://sap.github.io/jenkins-library/steps/abapEnvironmentCloneGitRepo/), [abapEnvironmentCheckoutBranch](https://sap.github.io/jenkins-library/steps/abapEnvironmentCheckoutBranch/)|
|
||||
| [Test](stages/Test.md) | [abapEnvironmentRunATCCheck](https://sap.github.io/jenkins-library/steps/abapEnvironmentRunATCCheck/), [abapEnvironmentRunAUnitTest](https://sap.github.io/jenkins-library/steps/abapEnvironmentRunAUnitTest/)|
|
||||
| [Test](stages/Test.md) | [abapEnvironmentRunATCCheck](https://sap.github.io/jenkins-library/steps/abapEnvironmentRunATCCheck/), [abapEnvironmentRunAUnitTest](https://sap.github.io/jenkins-library/steps/abapEnvironmentRunAUnitTest/), [abapEnvironmentPushATCSystemConfig](https://sap.github.io/jenkins-library/steps/abapEnvironmentPushATCSystemConfig/)|
|
||||
| [Build](stages/build.md) | [cloudFoundryCreateServiceKey](https://sap.github.io/jenkins-library/steps/cloudFoundryCreateServiceKey/), [abapEnvironmentAssemblePackages](https://sap.github.io/jenkins-library/steps/abapEnvironmentAssemblePackages/), [abapAddonAssemblyKitRegisterPackages](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitRegisterPackages/), [abapAddonAssemblyKitReleasePackages](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitReleasePackages/), [abapEnvironmentAssembleConfirm](https://sap.github.io/jenkins-library/steps/abapEnvironmentAssembleConfirm/), [abapAddonAssemblyKitCreateTargetVector](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitCreateTargetVector/), [abapAddonAssemblyKitPublishTargetVector](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitPublishTargetVector/)|
|
||||
| [Integration Tests](stages/integrationTest.md) | [abapEnvironmentCreateSystem](https://sap.github.io/jenkins-library/steps/abapEnvironmentCreateSystem/), [cloudFoundryDeleteService](https://sap.github.io/jenkins-library/steps/cloudFoundryDeleteService/)|
|
||||
| [Confirm](stages/confirm.md) | - |
|
||||
|
@ -7,6 +7,7 @@ The below sections contain more information on the usage and configuration of th
|
||||
## ATC
|
||||
|
||||
In this stage, ATC checks can be executed using [abapEnvironmentRunATCCheck](https://sap.github.io/jenkins-library/steps/abapEnvironmentRunATCCheck/). The step can receive software components or packages.
|
||||
In case an ATC System Configuration should be used, it can be created/updated using [abapEnvironmentPushATCSystemConfig](https://sap.github.io/jenkins-library/steps/abapEnvironmentPushATCSystemConfig/).
|
||||
|
||||
The results are returned in the checkstyle format and can be displayed using the [Warnings Next Generation Plugin](https://www.jenkins.io/doc/pipeline/steps/warnings-ng/#warnings-next-generation-plugin). To display the results it is necessary to [extend the ATC stage via the Checkstyle/Warnings Next Generation Plugin](https://www.project-piper.io/pipelines/abapEnvironment/extensibility/#1-extend-the-atc-stage-via-the-checkstylewarnings-next-generation-plugin).
|
||||
|
||||
@ -16,6 +17,7 @@ Alternatively it is possible to [extend the ATC stage to send ATC results via E-
|
||||
|
||||
The following steps are executed in this stage:
|
||||
|
||||
- [abapEnvironmentPushATCSystemConfig](../../../steps/abapEnvironmentPushATCSystemConfig.md)
|
||||
- [abapEnvironmentRunATCCheck](../../../steps/abapEnvironmentRunATCCheck.md)
|
||||
|
||||
### Stage Parameters
|
||||
@ -30,6 +32,8 @@ This stage will be active, if the stage configuration in the `config.yml` contai
|
||||
|
||||
#### config.yml
|
||||
|
||||
In case of NOT providing an ATC System Configuration.
|
||||
|
||||
```yaml
|
||||
general:
|
||||
cfApiEndpoint: 'https://api.cf.sap.hana.ondemand.com'
|
||||
@ -43,6 +47,22 @@ stages:
|
||||
atcConfig: 'atcConfig.yml'
|
||||
```
|
||||
|
||||
In case of providing an ATC System Configuration.
|
||||
|
||||
```yaml
|
||||
general:
|
||||
cfApiEndpoint: 'https://api.cf.sap.hana.ondemand.com'
|
||||
cfOrg: 'myOrg'
|
||||
cfSpace: 'mySpace'
|
||||
cfCredentialsId: 'cfAuthentification'
|
||||
cfServiceInstance: 'abap_system'
|
||||
cfServiceKeyName: 'JENKINS_SAP_COM_0510'
|
||||
stages:
|
||||
ATC:
|
||||
atcConfig: 'atcConfig.yml'
|
||||
atcSystemConfigFilePath: 'atcSystemConfig.json'
|
||||
```
|
||||
|
||||
#### atcConfig.yml
|
||||
|
||||
```yaml
|
||||
@ -51,6 +71,19 @@ atcobjects:
|
||||
- name: "/DMO/SWC"
|
||||
```
|
||||
|
||||
#### atcSystemConfig.json
|
||||
|
||||
```json
|
||||
{
|
||||
"conf_name": "myATCSystemConfigurationName",
|
||||
"checkvariant": "SAP_CLOUD_PLATFORM_ATC_DEFAULT",
|
||||
"block_findings": "0",
|
||||
"inform_findings": "1",
|
||||
"is_default": false,
|
||||
"is_proxy_variant": false
|
||||
}
|
||||
```
|
||||
|
||||
#### ATC.groovy
|
||||
|
||||
```groovy
|
||||
|
139
documentation/docs/steps/abapEnvironmentPushATCSystemConfig.md
Normal file
139
documentation/docs/steps/abapEnvironmentPushATCSystemConfig.md
Normal file
@ -0,0 +1,139 @@
|
||||
# ${docGenStepName}
|
||||
|
||||
## ${docGenDescription}
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* A SAP BTP, ABAP environment system is available. On this system, a [Communication User](https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/0377adea0401467f939827242c1f4014.html), a [Communication System](https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/1bfe32ae08074b7186e375ab425fb114.html) and a [Communication Arrangement](https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/a0771f6765f54e1c8193ad8582a32edb.html) is setup for the Communication Scenario “ABAP Test Cockpit Configuration Integration (SAP_COM_0763)“. This can be done manually through the respective applications on the SAP BTP, ABAP environment system or through creating a service key for the system on Cloud Foundry with the parameters {“scenario_id”: “SAP_COM_0763", “type”: “basic”}. In a pipeline, you can do this with the step [cloudFoundryCreateServiceKey](https://sap.github.io/jenkins-library/steps/cloudFoundryCreateServiceKey/).
|
||||
* You can either provide the ABAP endpoint configuration to directly trigger an ATC run on the ABAP system or optionally provide the Cloud Foundry parameters with your credentials to read a Service Key of a SAP BTP, ABAP environment system in Cloud Foundry that contains all the details of the ABAP endpoint to trigger an ATC run.
|
||||
* Regardless if you chose an ABAP endpoint directly or reading a Cloud Foundry Service Key, you have to provide the configuration of the packages and software components you want to be checked in an ATC run in a .yml or .yaml file. This file must be stored in the same folder as the Jenkinsfile defining the pipeline.
|
||||
* The software components and/or packages you want to be checked must be present in the configured system in order to run the check. Please make sure that you have created or pulled the respective software components and/or Packages in the SAP BTP, ABAP environment system.
|
||||
|
||||
Examples will be listed below.
|
||||
|
||||
## ${docGenParameters}
|
||||
|
||||
## ${docGenConfiguration}
|
||||
|
||||
## ${docJenkinsPluginDependencies}
|
||||
|
||||
## Examples
|
||||
|
||||
### Configuration in the config.yml
|
||||
|
||||
The recommended way to configure your pipeline is via the config.yml file. In this case, calling the step in the Jenkinsfile is reduced to one line:
|
||||
|
||||
```groovy
|
||||
abapEnvironmentPushATCSystemConfig script: this
|
||||
```
|
||||
|
||||
If you want to provide the host and credentials of the Communication Arrangement directly, the configuration could look as follows:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
abapEnvironmentPushATCSystemConfig:
|
||||
abapCredentialsId: 'abapCredentialsId',
|
||||
host: 'https://myABAPendpoint.com',
|
||||
atcSystemConfigFilePath: 'atcSystemConfig.json',
|
||||
```
|
||||
|
||||
To trigger a create/update ATC System Configuration step an ATC System configuration file `atcSystemConfig.json` will be needed. Check section 'ATC System Configuration file example' for more information.
|
||||
|
||||
### Create/Update an ATC System Configuration via Cloud Foundry Service Key example in Jenkinsfile
|
||||
|
||||
The following example triggers a Create/Update operation on an ATC System Configuration via reading the Service Key of an ABAP instance in Cloud Foundry.
|
||||
|
||||
You can store the credentials in Jenkins and use the cfCredentialsId parameter to authenticate to Cloud Foundry.
|
||||
The username and password to authenticate to ABAP system will then be read from the Cloud Foundry service key that is bound to the ABAP instance.
|
||||
|
||||
This can be done accordingly:
|
||||
|
||||
```groovy
|
||||
abapEnvironmentPushATCSystemConfig(
|
||||
cfApiEndpoint : 'https://test.server.com',
|
||||
cfOrg : 'cfOrg',
|
||||
cfSpace: 'cfSpace',
|
||||
cfServiceInstance: 'myServiceInstance',
|
||||
cfServiceKeyName: 'myServiceKey',
|
||||
abapCredentialsId: 'cfCredentialsId',
|
||||
atcSystemConfigFilePath: 'atcSystemConfig.json',
|
||||
script: this,
|
||||
)
|
||||
```
|
||||
|
||||
### Create/Update an ATC System Configuration via direct ABAP endpoint configuration in Jenkinsfile
|
||||
|
||||
This example triggers a create/update operation on an ATC System Configuration run directly on the ABAP endpoint.
|
||||
|
||||
In order to trigger the create/update operation on an ATC System Configuration you have to pass the username and password for authentication to the ABAP endpoint via parameters as well as the ABAP endpoint/host. You can store the credentials in Jenkins and use the abapCredentialsId parameter to authenticate to the ABAP endpoint/host.
|
||||
|
||||
This must be configured as following:
|
||||
|
||||
```groovy
|
||||
abapEnvironmentPushATCSystemConfig(
|
||||
abapCredentialsId: 'abapCredentialsId',
|
||||
host: 'https://myABAPendpoint.com',
|
||||
atcSystemConfigFilePath: 'atcSystemConfig.json',
|
||||
script: this,
|
||||
)
|
||||
```
|
||||
|
||||
To create/update an ATC System Configuration a file `atcSystemConfig.json` will be needed. Check section 'ATC System configuration file example' for more information.
|
||||
|
||||
### ATC System configuration file example
|
||||
|
||||
The step always performs a check first, if an ATC System Configuration with the same name provided in the file `atcSystemConfig.json` with the attribute conf_name.
|
||||
This file contains an JSON Representation of an ATC System Configuration. Some json file examples can be found below.
|
||||
In case an ATC System Configuration with this name already exists, by default, the step would perform an update of this ATC System Configuration with the ATC System Configuration information provided in file `atcSystemConfig.json`.
|
||||
If this is not desired, an update could be supressed by using the parameter patchIfExisting in the configuration yaml the follwoing way:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
abapEnvironmentPushATCSystemConfig:
|
||||
atcSystemConfigFilePath: atcSystemConfig.json,
|
||||
patchIfExisting: false,
|
||||
```
|
||||
|
||||
In this case the step skips further processing after existence check and returns with a Warning.
|
||||
|
||||
Providing a specifc System configuration file `atcSystemConfig.json` is mandatory.
|
||||
|
||||
The following section contains an example of an `atcSystemConfig.json` file.
|
||||
|
||||
This file must be stored in the same Git folder where the `Jenkinsfile` is stored to run the pipeline. This folder must be taken as a SCM in the Jenkins pipeline to run the pipeline.
|
||||
|
||||
See below an example for an `atcSystemConfig.json` file for creating/updating an ATC System Configuration with the name myATCSystemConfigurationName including a change of one priority and providing information about last_changed date (not mandatory).
|
||||
|
||||
```json
|
||||
{
|
||||
"last_changed_at": "2022-01-27T22:46:02.132169Z",
|
||||
"conf_name": "myATCSystemConfigurationName",
|
||||
"checkvariant": "SAP_CLOUD_PLATFORM_ATC_DEFAULT",
|
||||
"block_findings": "0",
|
||||
"inform_findings": "1",
|
||||
"is_default": false,
|
||||
"is_proxy_variant": false,
|
||||
"_priorities": [
|
||||
{
|
||||
"test": "CL_CI_TEST_AMDP_HDB_MIGRATION",
|
||||
"message_id": "FAIL_ABAP",
|
||||
"priority": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
See below an example for an `atcSystemConfig.json` file for creating/updating an ATC System Configuration with the name myATCSystemConfigurationName.
|
||||
|
||||
```json
|
||||
{
|
||||
"conf_name": "myATCSystemConfigurationName",
|
||||
"checkvariant": "SAP_CLOUD_PLATFORM_ATC_DEFAULT",
|
||||
"block_findings": "0",
|
||||
"inform_findings": "1",
|
||||
"is_default": false,
|
||||
"is_proxy_variant": false
|
||||
}
|
||||
```
|
||||
|
||||
In case of creating an ATC System Configuration the default priorities will be created as well. In case the field/attribute last_changed_at is provided in the file and filled with a valid date and the configuration already exists with the given name in the respective ABAP system and should be patched (configuration parameter patchIfExisting set to true), the step will only attempt an update, in case the date from the file is younger than the date from the system!
|
@ -123,6 +123,7 @@ public class CommonStepsTest extends BasePiperTest{
|
||||
'abapEnvironmentRunATCCheck', //implementing new golang pattern without fields
|
||||
'abapEnvironmentRunAUnitTest', //implementing new golang pattern without fields
|
||||
'abapEnvironmentCreateSystem', //implementing new golang pattern without fields
|
||||
'abapEnvironmentPushATCSystemConfig', //implementing new golang pattern without fields
|
||||
'artifactPrepareVersion',
|
||||
'cloudFoundryCreateService', //implementing new golang pattern without fields
|
||||
'cloudFoundryCreateServiceKey', //implementing new golang pattern without fields
|
||||
|
@ -33,6 +33,7 @@ class AbapEnvironmentPipelineStageATCTest extends BasePiperTest {
|
||||
return body()
|
||||
})
|
||||
helper.registerAllowedMethod('abapEnvironmentRunATCCheck', [Map.class], {m -> stepsCalled.add('abapEnvironmentRunATCCheck')})
|
||||
helper.registerAllowedMethod('abapEnvironmentPushATCSystemConfig', [Map.class], {m -> stepsCalled.add('abapEnvironmentPushATCSystemConfig')})
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -42,5 +43,16 @@ class AbapEnvironmentPipelineStageATCTest extends BasePiperTest {
|
||||
jsr.step.abapEnvironmentPipelineStageATC(script: nullScript)
|
||||
|
||||
assertThat(stepsCalled, hasItems('abapEnvironmentRunATCCheck'))
|
||||
assertThat(stepsCalled, not(hasItems('abapEnvironmentPushATCSystemConfig')))
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAbapEnvironmentRunTestsWithATCSystemConfig() {
|
||||
|
||||
nullScript.commonPipelineEnvironment.configuration.runStage = []
|
||||
jsr.step.abapEnvironmentPipelineStageATC(script: nullScript, atcSystemConfigFilePath: 'atcSystemConfig.json' )
|
||||
|
||||
assertThat(stepsCalled, hasItems('abapEnvironmentRunATCCheck'))
|
||||
assertThat(stepsCalled, hasItems('abapEnvironmentPushATCSystemConfig'))
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,10 @@
|
||||
import groovy.transform.Field
|
||||
import com.cloudbees.groovy.cps.NonCPS
|
||||
import com.sap.piper.GenerateStageDocumentation
|
||||
import groovy.transform.Field
|
||||
import com.sap.piper.Utils
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.ConfigurationLoader
|
||||
|
||||
import static com.sap.piper.Prerequisites.checkScript
|
||||
|
||||
@ -8,18 +12,35 @@ import static com.sap.piper.Prerequisites.checkScript
|
||||
@Field Set GENERAL_CONFIG_KEYS = []
|
||||
@Field STAGE_STEP_KEYS = [
|
||||
/** Starts an ATC check run on the ABAP Environment instance */
|
||||
'abapEnvironmentRunATCCheck'
|
||||
'abapEnvironmentRunATCCheck',
|
||||
/** Creates/Updates ATC System Configuration */
|
||||
'abapEnvironmentPushATCSystemConfig',
|
||||
/** Parameter for ATC System Configuration json */
|
||||
'atcSystemConfigFilePath'
|
||||
]
|
||||
@Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus(STAGE_STEP_KEYS)
|
||||
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
|
||||
/**
|
||||
* This stage runs the ATC Checks
|
||||
* This stage runs the ATC Checks & create/update ATC System Configuration before in case File Location provided
|
||||
*/
|
||||
void call(Map parameters = [:]) {
|
||||
def script = checkScript(this, parameters) ?: this
|
||||
def stageName = parameters.stageName?:env.STAGE_NAME
|
||||
|
||||
// load default & individual configuration
|
||||
Map config = ConfigurationHelper.newInstance(this)
|
||||
.loadStepDefaults([:], stageName)
|
||||
.mixin(ConfigurationLoader.defaultStageConfiguration(script, stageName))
|
||||
.mixinGeneralConfig(script.commonPipelineEnvironment, GENERAL_CONFIG_KEYS)
|
||||
.mixinStepConfig(script.commonPipelineEnvironment, STEP_CONFIG_KEYS)
|
||||
.mixinStageConfig(script.commonPipelineEnvironment, stageName, STEP_CONFIG_KEYS)
|
||||
.mixin(parameters, PARAMETER_KEYS)
|
||||
.use()
|
||||
|
||||
piperStageWrapper (script: script, stageName: stageName, stashContent: [], stageLocking: false) {
|
||||
if (config.atcSystemConfigFilePath) {
|
||||
abapEnvironmentPushATCSystemConfig script: parameters.script
|
||||
}
|
||||
abapEnvironmentRunATCCheck script: parameters.script
|
||||
}
|
||||
}
|
||||
|
11
vars/abapEnvironmentPushATCSystemConfig.groovy
Normal file
11
vars/abapEnvironmentPushATCSystemConfig.groovy
Normal file
@ -0,0 +1,11 @@
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field String STEP_NAME = getClass().getName()
|
||||
@Field String METADATA_FILE = 'metadata/abapEnvironmentPushATCSystemConfig.yaml'
|
||||
|
||||
void call(Map parameters = [:]) {
|
||||
List credentials = [
|
||||
[type: 'usernamePassword', id: 'abapCredentialsId', env: ['PIPER_username', 'PIPER_password']]
|
||||
]
|
||||
piperExecuteBin(parameters, STEP_NAME, METADATA_FILE, credentials, false, false, true)
|
||||
}
|
Loading…
Reference in New Issue
Block a user