github.com/ouraigua/jenkins-library@v0.0.0-20231028010029-fbeaf2f3aa9b/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/docs/ABAP_PLATFORM_NEW/ba879a6e2ea04d9bb94c7ccd7cdac446/62c41ad841554516bb06fb3620540e47.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/docs/ABAP_PLATFORM_NEW/ba879a6e2ea04d9bb94c7ccd7cdac446/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/docs/ABAP_PLATFORM_NEW/4a368c163b08418890a406d413933ba7/f319b168e87e42149e25e13c08d002b9.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 queryparameters: [saml2: 'disabled'] 38 39 ) 40 ``` 41 42 Example configuration for the use in a yaml config file (such as `.pipeline/config.yaml`). 43 44 ```yaml 45 steps: 46 <...> 47 gctsExecuteABAPUnitTests: 48 host: 'https://abap.server.com:port' 49 client: '000' 50 abapCredentialsId: 'ABAPUserPasswordCredentialsId' 51 repository: 'myrepo' 52 scope: 'remoteChangedObjects' 53 commit: '38abb4814ae46b98e8e6c3e718cf1782afa9ca90' 54 workspace: '/var/jenkins_home/workspace/myFirstPipeline' 55 ``` 56 57 Example configuration when you define scope: *repository* or *packages*. For these two cases you do not need to specify a *commit*. 58 59 ```yaml 60 steps: 61 <...> 62 gctsExecuteABAPUnitTests: 63 host: 'https://abap.server.com:port' 64 client: '000' 65 abapCredentialsId: 'ABAPUserPasswordCredentialsId' 66 repository: 'myrepo' 67 scope: 'repository' 68 workspace: '/var/jenkins_home/workspace/myFirstPipeline' 69 ``` 70 71 Example configuration when you want to execute only ABAP Unit Test. 72 73 ```yaml 74 steps: 75 <...> 76 gctsExecuteABAPUnitTests: 77 host: 'https://abap.server.com:port' 78 client: '000' 79 abapCredentialsId: 'ABAPUserPasswordCredentialsId' 80 repository: 'myrepo' 81 atcCheck: false 82 scope: 'packages' 83 workspace: '/var/jenkins_home/workspace/myFirstPipeline' 84 ``` 85 86 Example configuration for the use of *recordIssue* step to make the findings visible in Jenkins interface. 87 88 ```groovy 89 stage('ABAP Unit Tests') { 90 steps{ 91 92 script{ 93 94 try{ 95 gctsExecuteABAPUnitTests( 96 script: this, 97 commit: "${env.GIT_COMMIT}", 98 workspace: "${WORKSPACE}") 99 } 100 catch (Exception ex) { 101 currentBuild.result = 'FAILURE' 102 unstable(message: "${STAGE_NAME} is unstable") 103 } 104 105 } 106 } 107 } 108 stage('Results in Checkstyle') { 109 steps{ 110 111 recordIssues( 112 enabledForFailure: true, aggregatingResults: true, 113 tools: [checkStyle(pattern: 'ATCResults.xml', reportEncoding: 'UTF8'),checkStyle(pattern: 'AUnitResults.xml', reportEncoding: 'UTF8')] 114 ) 115 116 } 117 } 118 119 } 120 ``` 121 122 **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. 123 124 ```groovy 125 recordIssues( 126 enabledForFailure: true, aggregatingResults: true, 127 tools: [checkStyle(pattern: 'AUnitResults.xml', reportEncoding: 'UTF8')] 128 129 ) 130 ```