github.com/jaylevin/jenkins-library@v1.230.4/documentation/docs/steps/gctsExecuteABAPUnitTests.md (about)

     1  # ${docGenStepName}
     2  
     3  ## ${docGenDescription}
     4  
     5  !!! caution "This step is deprecated."
     6      Please use the [gctsExecuteABAPQualityChecks](https://www.project-piper.io/steps/gctsExecuteABAPQualityChecks/) instead.
     7      Don´t worry, if you´re already using the step. You can continue to use it. It will call the functions of the [gctsExecuteABAPQualityChecks](https://www.project-piper.io/steps/gctsExecuteABAPQualityChecks/) step.
     8  
     9  ## Prerequisites
    10  
    11  * [ATC](https://help.sap.com/viewer/c238d694b825421f940829321ffa326a/202110.000/en-US/4ec5711c6e391014adc9fffe4e204223.html) checks are enabled in transaction ATC in the ABAP systems where you want to use the step.
    12  * [ABAP Unit tests](https://help.sap.com/viewer/ba879a6e2ea04d9bb94c7ccd7cdac446/latest/en-US/491cfd8926bc14cde10000000a42189b.html) 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.
    13  * [gCTS](https://help.sap.com/viewer/4a368c163b08418890a406d413933ba7/latest/en-US/26c9c6c5a89244cb9506c253d36c3fda.html) is available and configured in the ABAP systems where you want to use the step.
    14  * If you want to use environmental variables as parameters, for example, `GIT_COMMIT`: The [Git Plugin](https://plugins.jenkins.io/git/) is installed in Jenkins.
    15  * The [Warnings-Next-Generation](https://plugins.jenkins.io/warnings-ng/) Plugin is installed in Jenkins.
    16  
    17  ## ${docGenParameters}
    18  
    19  ## ${docGenConfiguration}
    20  
    21  ## ${docJenkinsPluginDependencies}
    22  
    23  ## Example
    24  
    25  Example configuration for the use in a Jenkinsfile.
    26  
    27  ```groovy
    28  gctsExecuteABAPUnitTests(
    29    script: this,
    30    host: 'https://abap.server.com:port',
    31    client: '000',
    32    abapCredentialsId: 'ABAPUserPasswordCredentialsId',
    33    repository: 'myrepo',
    34    scope: 'remoteChangedObjects',
    35    commit: "${env.GIT_COMMIT}",
    36    workspace: "${WORKSPACE}"
    37  
    38    )
    39  ```
    40  
    41  Example configuration for the use in a yaml config file (such as `.pipeline/config.yaml`).
    42  
    43  ```yaml
    44  steps:
    45    <...>
    46    gctsExecuteABAPUnitTests:
    47      host: 'https://abap.server.com:port'
    48      client: '000'
    49      abapCredentialsId: 'ABAPUserPasswordCredentialsId'
    50      repository: 'myrepo'
    51      scope: 'remoteChangedObjects'
    52      commit: '38abb4814ae46b98e8e6c3e718cf1782afa9ca90'
    53      workspace: '/var/jenkins_home/workspace/myFirstPipeline'
    54  ```
    55  
    56  Example configuration when you define scope: *repository* or *packages*. For these two cases you do not need to specify a *commit*.
    57  
    58  ```yaml
    59  steps:
    60    <...>
    61    gctsExecuteABAPUnitTests:
    62      host: 'https://abap.server.com:port'
    63      client: '000'
    64      abapCredentialsId: 'ABAPUserPasswordCredentialsId'
    65      repository: 'myrepo'
    66      scope: 'repository'
    67      workspace: '/var/jenkins_home/workspace/myFirstPipeline'
    68  ```
    69  
    70  Example configuration when you want to execute only ABAP Unit Test.
    71  
    72  ```yaml
    73  steps:
    74    <...>
    75    gctsExecuteABAPUnitTests:
    76      host: 'https://abap.server.com:port'
    77      client: '000'
    78      abapCredentialsId: 'ABAPUserPasswordCredentialsId'
    79      repository: 'myrepo'
    80      atcCheck: false
    81      scope: 'packages'
    82      workspace: '/var/jenkins_home/workspace/myFirstPipeline'
    83  ```
    84  
    85  Example configuration for the use of *recordIssue* step to make the findings visible in Jenkins interface.
    86  
    87  ```groovy
    88  stage('ABAP Unit Tests') {
    89    steps{
    90  
    91     script{
    92  
    93       try{
    94             gctsExecuteABAPUnitTests(
    95                script: this,
    96                commit: "${env.GIT_COMMIT}",
    97                workspace: "${WORKSPACE}")
    98          }
    99            catch (Exception ex) {
   100              currentBuild.result = 'FAILURE'
   101              unstable(message: "${STAGE_NAME} is unstable")
   102               }
   103  
   104          }
   105        }
   106      }
   107  stage('Results in Checkstyle') {
   108    steps{
   109  
   110       recordIssues(
   111            enabledForFailure: true, aggregatingResults: true,
   112            tools: [checkStyle(pattern: 'ATCResults.xml', reportEncoding: 'UTF8'),checkStyle(pattern: 'AUnitResults.xml', reportEncoding: 'UTF8')]
   113         )
   114  
   115        }
   116      }
   117  
   118  }
   119  ```
   120  
   121  **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.
   122  
   123  ```groovy
   124  recordIssues(
   125    enabledForFailure: true, aggregatingResults: true,
   126    tools: [checkStyle(pattern: 'AUnitResults.xml', reportEncoding: 'UTF8')]
   127  
   128  )
   129  ```