1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-04-11 11:41:53 +02:00
sap-jenkins-library/documentation/docs/steps/gctsExecuteABAPUnitTests.md
Anke Ravalitera b6a5ceaa03
Update gCTS steps (#3673)
* gCTS Scenario and two images

* Updated gCTS Scenario

* updated gCTS_Scenario.md and images

* added checkstyle stage

* upated the gCTSExecuteABAPQualityChecks.yaml file with severity information

* updates to gCTSExecuteABAPQualityChecks and gCTSExecuteABAPUnitTests steps

* updated gCTS_Scenario.md and relevant images

* Add more explanation for workspace parameter, change atc variant default value to DEFAULT

* Fix a type in description of workspace parameter

* changes to gctsExecuteABApUnitTests.md gctsExecuteABAPQualityChecks.yaml and gctsExecuteABApUnitTests.yaml

* final updates to gCTS steps and scenario

* added env. to GIT_COMMIT in gCTSExecuteABAPQualityChecks.md and gCTSExecuteABAPUnitTests.md

* remove the gScenario description from the branch

* Correct column typo in yaml file and generate files

* Add a new line in docu for gCTSExecuteABAPUnitTests

* Remove blank line from docu in gctsExecuteABAPUnitTests

Co-authored-by: Rinita Asani <rinita.asani@sap.com>
Co-authored-by: Sarat Krishnan <78093145+sarat-krk@users.noreply.github.com>
2022-03-29 21:24:10 +02:00

4.2 KiB

${docGenStepName}

${docGenDescription}

!!! caution "This step has been deprecated." Please use the gctsExecuteABAPQualityChecks instead. Don´t worry, if you´re already using the step. You can continue to use it. It will call the functions of the gctsExecuteABAPQualityChecks step.

Prerequisites

  • ATC checks are enabled in transaction ATC in the ABAP systems where you want to use the step.
  • ABAP Unit tests are available for the source code that you want to check. Note: Do not execute unit tests in client 000, and not in your production client.
  • gCTS is available and configured in the ABAP systems where you want to use the step.
  • If you want to use environmental variables as parameters, for example, GIT_COMMIT: The Git Plugin is installed in Jenkins.
  • The Warnings-Next-Generation Plugin is installed in Jenkins.

${docGenParameters}

${docGenConfiguration}

${docJenkinsPluginDependencies}

Example

Example configuration for the use in a Jenkinsfile.

gctsExecuteABAPUnitTests(
  script: this,
  host: 'https://abap.server.com:port',
  client: '000',
  abapCredentialsId: 'ABAPUserPasswordCredentialsId',
  repository: 'myrepo',
  scope: 'remoteChangedObjects',
  commit: "${env.GIT_COMMIT}",
  workspace: "${WORKSPACE}"

  )

Example configuration for the use in a yaml config file (such as .pipeline/config.yaml).

steps:
  <...>
  gctsExecuteABAPUnitTests:
    host: 'https://abap.server.com:port'
    client: '000'
    abapCredentialsId: 'ABAPUserPasswordCredentialsId'
    repository: 'myrepo'
    scope: 'remoteChangedObjects'
    commit: '38abb4814ae46b98e8e6c3e718cf1782afa9ca90'
    workspace: '/var/jenkins_home/workspace/myFirstPipeline'

Example configuration when you define scope: repository or packages. For these two cases you do not need to specify a commit.

steps:
  <...>
  gctsExecuteABAPUnitTests:
    host: 'https://abap.server.com:port'
    client: '000'
    abapCredentialsId: 'ABAPUserPasswordCredentialsId'
    repository: 'myrepo'
    scope: 'repository'
    workspace: '/var/jenkins_home/workspace/myFirstPipeline'

Example configuration when you want to execute only ABAP Unit Test.

steps:
  <...>
  gctsExecuteABAPUnitTests:
    host: 'https://abap.server.com:port'
    client: '000'
    abapCredentialsId: 'ABAPUserPasswordCredentialsId'
    repository: 'myrepo'
    atcCheck: false
    scope: 'packages'
    workspace: '/var/jenkins_home/workspace/myFirstPipeline'

Example configuration for the use of recordIssue step to make the findings visible in Jenkins interface.

stage('ABAP Unit Tests') {
  steps{

   script{

     try{
           gctsExecuteABAPUnitTests(
              script: this,
              commit: "${env.GIT_COMMIT}",
              workspace: "${WORKSPACE}")
        }
          catch (Exception ex) {
            currentBuild.result = 'FAILURE'
            unstable(message: "${STAGE_NAME} is unstable")
             }

        }
      }
    }
stage('Results in Checkstyle') {
  steps{

     recordIssues(
          enabledForFailure: true, aggregatingResults: true,
          tools: [checkStyle(pattern: 'ATCResults.xml', reportEncoding: 'UTF8'),checkStyle(pattern: 'AUnitResults.xml', reportEncoding: 'UTF8')]
       )

      }
    }

}

Note: If you have disabled atcCheck or aUnitTest, than you also need to remove the corresponding ATCResults.xml or AUnitResults.xml from recordIssues step. In the example below the atcCheck was disabled, so ATCResults.xml was removed.

recordIssues(
  enabledForFailure: true, aggregatingResults: true,
  tools: [checkStyle(pattern: 'AUnitResults.xml', reportEncoding: 'UTF8')]

)