github.com/xgoffin/jenkins-library@v1.154.0/documentation/docs/steps/gctsExecuteABAPUnitTests.md (about) 1 # ${docGenStepName} 2 3 ## ${docGenDescription} 4 5 ## Prerequisites 6 7 * [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. 8 * [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. 9 * The [Warnings-Next-Generation](https://plugins.jenkins.io/warnings-ng/) Plugin is installed in Jenkins. 10 11 ## ${docGenParameters} 12 13 ## ${docGenConfiguration} 14 15 ## ${docJenkinsPluginDependencies} 16 17 ## Example 18 19 Example configuration for the use in a Jenkinsfile. 20 21 ```groovy 22 gctsExecuteABAPUnitTests( 23 script: this, 24 host: 'https://abap.server.com:port', 25 client: '000', 26 abapCredentialsId: 'ABAPUserPasswordCredentialsId', 27 repository: 'myrepo', 28 scope: 'remoteChangedObjects', 29 commit: "${GIT_COMMIT}", 30 workspace: "${WORKSPACE}" 31 32 ) 33 ``` 34 35 Example configuration for the use in a yaml config file (such as `.pipeline/config.yaml`). 36 37 ```yaml 38 steps: 39 <...> 40 gctsExecuteABAPUnitTests: 41 host: 'https://abap.server.com:port' 42 client: '000' 43 abapCredentialsId: 'ABAPUserPasswordCredentialsId' 44 repository: 'myrepo' 45 scope: 'remoteChangedObjects' 46 commit: '38abb4814ae46b98e8e6c3e718cf1782afa9ca90' 47 workspace: '/var/jenkins_home/workspace/myFirstPipeline' 48 ``` 49 50 Example configuration when you define scope: *repository* or *packages*. For these two cases you do not need to specify a *commit*. 51 52 ```yaml 53 steps: 54 <...> 55 gctsExecuteABAPUnitTests: 56 host: 'https://abap.server.com:port' 57 client: '000' 58 abapCredentialsId: 'ABAPUserPasswordCredentialsId' 59 repository: 'myrepo' 60 scope: 'repository' 61 workspace: '/var/jenkins_home/workspace/myFirstPipeline' 62 ``` 63 64 Example configuration when you want to execute only ABAP Unit Test. 65 66 ```yaml 67 steps: 68 <...> 69 gctsExecuteABAPUnitTests: 70 host: 'https://abap.server.com:port' 71 client: '000' 72 abapCredentialsId: 'ABAPUserPasswordCredentialsId' 73 repository: 'myrepo' 74 atcCheck: false 75 scope: 'packages' 76 workspace: '/var/jenkins_home/workspace/myFirstPipeline' 77 ``` 78 79 Example configuration for the use of *recordIssue* step to make the findings visible in Jenkins interface. 80 81 ```groovy 82 stage('ABAP Unit Tests') { 83 steps{ 84 85 script{ 86 87 try{ 88 gctsExecuteABAPUnitTests( 89 script: this, 90 commit: "${GIT_COMMIT}", 91 workspace: "${WORKSPACE}") 92 } 93 catch (Exception ex) { 94 currentBuild.result = 'FAILURE' 95 unstable(message: "${STAGE_NAME} is unstable") 96 } 97 98 } 99 } 100 } 101 stage('Results in Checkstyle') { 102 steps{ 103 104 recordIssues( 105 enabledForFailure: true, aggregatingResults: true, 106 tools: [checkStyle(pattern: 'ATCResults.xml', reportEncoding: 'UTF8'),checkStyle(pattern: 'AUnitResults.xml', reportEncoding: 'UTF8')] 107 ) 108 109 } 110 } 111 112 } 113 ``` 114 115 **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. 116 117 ```groovy 118 recordIssues( 119 enabledForFailure: true, aggregatingResults: true, 120 tools: [checkStyle(pattern: 'AUnitResults.xml', reportEncoding: 'UTF8')] 121 122 ) 123 ```