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
Rinita Asani cd2ae89229
Local scopeg cts execute abap unit test (#3563)
* Adjust local changed objects with commit history

* fix the righ history entry

* fix for local packages commit history

* Adapt unit tests and fix for retry after 500

* Rename gctsExecuteABAPUnitTests to gctsExecuteABAPQualityChecks

* Add unit test file for gCTSExecuteABAPUnitTest

* add a test step

* gcts Test change files

* Add unit test for gCTS test

* adapt gctsTEST

* deletegcts

* command

* maintain old step

* Adapt changes to documentation

* fix for go generate
2022-02-22 09:58:22 +01:00

3.4 KiB

${docGenStepName}

${docGenDescription}

Prerequisites

  • ATC checks are enabled in transaction ATC in the ABAP systems where you want to use the step.
  • gCTS is available and configured in the ABAP systems where you want to use the step.
  • 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: "${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: "${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')]

)