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