1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-04-11 11:41:53 +02:00

Add stages for build process to ABAP Environment Pipeline (#2052)

* Add stages for build process

* fix typo

* Add createServiceKey to Build stage

* Fix typo

* Inital Checks is required when Build stage is exec

* Switch Order

* Fix Typo

* Add parameter for confirmation

* add "addIfEmpty"

* Add import

* revert

* revert2

* Remove import

* revert3

* Add stages to docu

* Update image
This commit is contained in:
Daniel Mieg 2020-10-02 17:03:43 +02:00 committed by GitHub
parent 91067d219a
commit ae213a013e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 247 additions and 9 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -1,8 +1,10 @@
# Configuration
In this section, you can learn how to create a configuration in a (GitHub) repository to run an ABAP Environment Pipeline. This sepcific example will create a pipeline, which executes ATC checks after creating a new ABAP Environment system. In the end, the system will be deprovisioned.
In genereal, the ABAP Environment pipeline supports different scenarios. The idea is that only configured stages are executed and the user is able to choose the appropriate stages.
In this section, you can learn how to create a configuration in a (GitHub) repository to run an ABAP Environment Pipeline used for testing. This sepcific example will create a pipeline, which executes ATC checks after creating a new ABAP Environment system. In the end, the system will be deprovisioned.
You can have a look at different pipeline configurations in our [SAP-samples repository](https://github.com/SAP-samples/abap-platform-ci-cd-samples).
Other scenarios (e.g. building an ABAP AddOn) will be added to the documentation soon.
## 1. Prerequisites

View File

@ -3,14 +3,19 @@
![ABAP Environment Pipeline](../../images/abapPipelineOverview.png)
The goal of the ABAP Environment Pipeline is to enable Continuous Integration for the SAP Cloud Platform ABAP Environment, also known as Steampunk.
In the current state, the pipeline enables you to pull Software Components to specifc systems and perform ATC checks. The following stages and steps are part of the pipeline:
The pipeline contains several stages and supports different scenarios. The general idea is that the user can choose a subset of these stages, which fit his/her use case, for example running nightly ATC checks or building an ABAP AddOn for Steampunk. The following stages and steps are part of the pipeline:
| Stage | Steps |
|--------------------------|-------|
| Init | - |
| Initial Checks | [abapAddonAssemblyKitCheckPV](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitCheckPV/), [abapAddonAssemblyKitCheckCVs](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitCheckCVs/)|
| Prepare System | [cloudFoundryCreateService](https://sap.github.io/jenkins-library/steps/cloudFoundryCreateService/), [cloudFoundryCreateServiceKey](https://sap.github.io/jenkins-library/steps/cloudFoundryCreateServiceKey/)|
| Clone Repositories | [abapEnvironmentPullGitRepo](https://sap.github.io/jenkins-library/steps/abapEnvironmentPullGitRepo/)|
| ATC | [abapEnvironmentRunATCCheck](https://sap.github.io/jenkins-library/steps/abapEnvironmentRunATCCheck/)|
| Build | [cloudFoundryCreateServiceKey](https://sap.github.io/jenkins-library/steps/cloudFoundryCreateServiceKey/), [abapAddonAssemblyKitReserveNextPackages](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitReserveNextPackages/), [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/), [abapAddonAssemblyKitCreateTargetVector](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitCreateTargetVector/), [abapAddonAssemblyKitPublishTargetVector](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitPublishTargetVector/)|
| Integration Tests | [cloudFoundryCreateService](https://sap.github.io/jenkins-library/steps/cloudFoundryCreateService/)|
| Confirm | - |
| Publish | [abapAddonAssemblyKitPublishTargetVector](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitPublishTargetVector/)|
| Post | [cloudFoundryDeleteService](https://sap.github.io/jenkins-library/steps/cloudFoundryDeleteService/)|
Below you can find more details about the different stages. [Here](configuration.md) you can find more information about how to configure your pipeline.
@ -19,6 +24,10 @@ Below you can find more details about the different stages. [Here](configuration
In this stage, the pipeline is initialized. Nothing to see here.
## Initial Checks
This stage is executed, if the "Build" stage is configured. It contains checks to verify the validity of the provided AddOn Descriptor.
## Prepare System
In this stage, the ABAP Environment system is created. This is done with the cloudFoundryCreateService step.
@ -39,6 +48,22 @@ The step can receive a list of Software Components / repositories and pulls them
In this stage, ATC checks can be executed using abapEnvironmentRunATCCheck. The step can receive Software Components or packages (configured in YML file - as described in [configuration](configuration.md)). The results are returned in the checkstlye format. With the use of a pipeline extension, quality gates can be configured (see [step documentation](https://sap.github.io/jenkins-library/steps/abapEnvironmentRunATCCheck/) or the "Extensions" section in the [configuration](configuration.md)).
## Build
This stage is responsible for building an ABAP AddOn for the SAP Cloud Platform ABAP Environment. The build process of the AddOn is done on a Steampunk system with the help of the ABAP Addon Assembly Kit as a Service (AAKaaS). After executing this stage successfully, the AddOn is ready to be tested.
## Integration Tests
This stage is intended to be used for testing the AddOn built in the "Build" stage. Nevertheless, it can be configured seperately. In this stage, another ABAP Environment system is created including the AddOn (if configured correctly).
## Confirm
This stage is executed if the stage "Publish" is configured. In this stage a manual confirmation is prompted to confirm the publishing of the AddOn.
## Publish
In this stage the AddOn built with this pipeline is published. After that, it is ready to be delivered to productive systems.
## Post
At the end of every pipeline (successful or unsuccessful), the system is deprovisioned using the step cloudFoundryDeleteService.

View File

@ -1,6 +1,11 @@
stages:
Init: {}
Initial Checks: {}
Prepare System: {}
Clone Repositories: {}
ATC: {}
Build: {}
Integration Tests: {}
Confirm: {}
Publish: {}
Post: {}

View File

@ -2,14 +2,29 @@ stages:
Init:
ordinal: 1
'Prepare System':
'Initial Checks':
ordinal: 10
ATC:
'Prepare System':
ordinal: 20
'Clone Repositories':
ordinal: 30
Post:
ATC:
ordinal: 40
Build:
ordinal: 50
'Integration Tests':
ordinal: 60
Confirm:
ordinal: 70
Publish:
ordinal: 80
Post:
ordinal: 90

View File

@ -4,12 +4,12 @@ Init:
- name: "source"
includes: "**/*"
'Prepare System':
'Initial Checks':
unstash:
- source
stashes: []
ATC:
'Prepare System':
unstash:
- source
stashes: []
@ -19,6 +19,31 @@ ATC:
- source
stashes: []
ATC:
unstash:
- source
stashes: []
Build:
unstash:
- source
stashes: []
'Integration Tests':
unstash:
- source
stashes: []
Confirm:
unstash:
- source
stashes: []
Publish:
unstash:
- source
stashes: []
Post:
unstash:
- source

View File

@ -12,6 +12,13 @@ void call(parameters) {
}
}
stage('Initial Checks') {
when {expression {return parameters.script.commonPipelineEnvironment.configuration.runStage?.get("Build")}}
steps {
abapEnvironmentPipelineStageInitialChecks script: parameters.script
}
}
stage('Prepare System') {
when {expression {return parameters.script.commonPipelineEnvironment.configuration.runStage?.get(env.STAGE_NAME)}}
steps {
@ -32,6 +39,35 @@ void call(parameters) {
abapEnvironmentPipelineStageATC script: parameters.script
}
}
stage('Build') {
when {expression {return parameters.script.commonPipelineEnvironment.configuration.runStage?.get(env.STAGE_NAME)}}
steps {
abapEnvironmentPipelineStageBuild script: parameters.script
}
}
stage('Integration Tests') {
when {expression {return parameters.script.commonPipelineEnvironment.configuration.runStage?.get(env.STAGE_NAME)}}
steps {
abapEnvironmentPipelineStageIntegrationTests script: parameters.script
}
}
stage('Confirm') {
when {expression {return parameters.script.commonPipelineEnvironment.configuration.runStage?.get("Publish")}}
steps {
abapEnvironmentPipelineStageConfirm script: parameters.script
}
}
stage('Publish') {
when {expression {return parameters.script.commonPipelineEnvironment.configuration.runStage?.get(env.STAGE_NAME)}}
steps {
abapEnvironmentPipelineStagePublish script: parameters.script
}
}
}
post {
/* https://jenkins.io/doc/book/pipeline/syntax/#post */

View File

@ -0,0 +1,36 @@
import groovy.transform.Field
import com.sap.piper.Utils
import static com.sap.piper.Prerequisites.checkScript
@Field String STEP_NAME = getClass().getName()
@Field Set GENERAL_CONFIG_KEYS = []
@Field STAGE_STEP_KEYS = [
'cloudFoundryCreateServiceKey',
'abapAddonAssemblyKitReserveNextPackages',
'abapEnvironmentAssemblePackages',
'abapAddonAssemblyKitRegisterPackages',
'abapAddonAssemblyKitReleasePackages',
'abapAddonAssemblyKitCreateTargetVector',
'abapAddonAssemblyKitPublishTargetVector'
]
@Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus(STAGE_STEP_KEYS)
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
/**
* This stage builds an AddOn for the SAP Cloud Platform ABAP Environment
*/
void call(Map parameters = [:]) {
def script = checkScript(this, parameters) ?: this
def stageName = parameters.stageName?:env.STAGE_NAME
piperStageWrapper (script: script, stageName: stageName, stashContent: [], stageLocking: false) {
cloudFoundryCreateServiceKey script: parameters.script
abapAddonAssemblyKitReserveNextPackages script: parameters.script
abapEnvironmentAssemblePackages script: parameters.script
abapAddonAssemblyKitRegisterPackages script: parameters.script
abapAddonAssemblyKitReleasePackages script: parameters.script
abapAddonAssemblyKitCreateTargetVector script: parameters.script
abapAddonAssemblyKitPublishTargetVector(script: parameters.script, targetVectorScope: 'T')
}
}

View File

@ -0,0 +1,22 @@
import groovy.transform.Field
import com.sap.piper.Utils
import static com.sap.piper.Prerequisites.checkScript
@Field String STEP_NAME = getClass().getName()
@Field Set GENERAL_CONFIG_KEYS = []
@Field STAGE_STEP_KEYS = []
@Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus(STAGE_STEP_KEYS)
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
/**
* This stage asks for the approval to publish the previously built AddOn for the SAP Cloud Platform ABAP Environment
*/
void call(Map parameters = [:]) {
def script = checkScript(this, parameters) ?: this
def stageName = parameters.stageName?:env.STAGE_NAME
piperStageWrapper (script: script, stageName: stageName, stashContent: [], stageLocking: false) {
input(message: 'Do you want to publish this AddOn Product?')
}
}

View File

@ -0,0 +1,26 @@
import groovy.transform.Field
import com.sap.piper.Utils
import static com.sap.piper.Prerequisites.checkScript
@Field String STEP_NAME = getClass().getName()
@Field Set GENERAL_CONFIG_KEYS = []
@Field STAGE_STEP_KEYS = [
'abapAddonAssemblyKitCheckPV',
'abapAddonAssemblyKitCheckCVs'
]
@Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus(STAGE_STEP_KEYS)
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
/**
* This stage runs initial checks for the build process for an AddOn for the SAP Cloud Platform ABAP Environment
*/
void call(Map parameters = [:]) {
def script = checkScript(this, parameters) ?: this
def stageName = parameters.stageName?:env.STAGE_NAME
piperStageWrapper (script: script, stageName: stageName, stashContent: [], stageLocking: false) {
abapAddonAssemblyKitCheckPV script: parameters.script
abapAddonAssemblyKitCheckCVs script: parameters.script
}
}

View File

@ -0,0 +1,24 @@
import groovy.transform.Field
import com.sap.piper.Utils
import static com.sap.piper.Prerequisites.checkScript
@Field String STEP_NAME = getClass().getName()
@Field Set GENERAL_CONFIG_KEYS = []
@Field STAGE_STEP_KEYS = [
'cloudFoundryCreateService'
]
@Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus(STAGE_STEP_KEYS)
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
/**
* This stage creates a system for Integration Tests. The (custom) tests themselves can be added via a stage extension.
*/
void call(Map parameters = [:]) {
def script = checkScript(this, parameters) ?: this
def stageName = parameters.stageName?:env.STAGE_NAME
piperStageWrapper (script: script, stageName: stageName, stashContent: [], stageLocking: false) {
cloudFoundryCreateService script: parameters.script
}
}

View File

@ -16,7 +16,6 @@ import static com.sap.piper.Prerequisites.checkScript
void call(Map parameters = [:]) {
def script = checkScript(this, parameters) ?: this
def stageName = parameters.stageName?:env.STAGE_NAME
stageName = stageName.replace('Declarative: ', '')
stageName = stageName.replace(' Actions', '')
@ -25,5 +24,4 @@ void call(Map parameters = [:]) {
cloudFoundryDeleteService script: parameters.script
}
}
}

View File

@ -0,0 +1,24 @@
import groovy.transform.Field
import com.sap.piper.Utils
import static com.sap.piper.Prerequisites.checkScript
@Field String STEP_NAME = getClass().getName()
@Field Set GENERAL_CONFIG_KEYS = []
@Field STAGE_STEP_KEYS = [
'abapEnvironmentAssemblyKitPublishTargetVector'
]
@Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus(STAGE_STEP_KEYS)
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
/**
* This stage publishes an AddOn for the SAP Cloud Platform ABAP Environment
*/
void call(Map parameters = [:]) {
def script = checkScript(this, parameters) ?: this
def stageName = parameters.stageName?:env.STAGE_NAME
piperStageWrapper (script: script, stageName: stageName, stashContent: [], stageLocking: false) {
abapAddonAssemblyKitPublishTargetVector(script: parameters.script, targetVectorScope: 'P')
}
}