github.com/xgoffin/jenkins-library@v1.154.0/documentation/docs/steps/abapEnvironmentCloneGitRepo.md (about)

     1  # ${docGenStepName}
     2  
     3  ## ${docGenDescription}
     4  
     5  ## Prerequisites
     6  
     7  A SAP BTP, ABAP environment system is available.
     8  On this system, a [Communication User](https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/0377adea0401467f939827242c1f4014.html), a [Communication System](https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/1bfe32ae08074b7186e375ab425fb114.html) and a [Communication Arrangement](https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/a0771f6765f54e1c8193ad8582a32edb.html) is setup for the Communication Scenario "SAP BTP, ABAP Environment - Software Component Test Integration (SAP_COM_0510)". This can be done manually through the respective applications on the SAP BTP, ABAP environment system or through creating a service key for the system on Cloud Foundry with the parameters {"scenario_id": "SAP_COM_0510", "type": "basic"}. In a pipeline, you can do this with the step [cloudFoundryCreateServiceKey](https://sap.github.io/jenkins-library/steps/cloudFoundryCreateServiceKey/). In addition, the software component should be cloned into the system instance. You can do this with the step [abapEnvironmentPullGitRepo](https://sap.github.io/jenkins-library/steps/abapEnvironmentPullGitRepo/).
     9  
    10  ## ${docGenParameters}
    11  
    12  ## ${docGenConfiguration}
    13  
    14  ## ${docJenkinsPluginDependencies}
    15  
    16  ## Example: Configuration in the config.yml
    17  
    18  The recommended way to configure your pipeline is via the config.yml file. In this case, calling the step in the Jenkinsfile is reduced to one line:
    19  
    20  ```groovy
    21  abapEnvironmentCheckoutBranch script: this
    22  ```
    23  
    24  If you want to provide the host and credentials of the Communication Arrangement directly, the configuration could look as follows:
    25  
    26  ```yaml
    27  steps:
    28    abapEnvironmentCloneGitRepo:
    29      repositoryName: '/DMO/GIT_REPOSITORY'
    30      branchName: 'my-demo-branch'
    31      abapCredentialsId: 'abapCredentialsId'
    32      host: '1234-abcd-5678-efgh-ijk.abap.eu10.hana.ondemand.com'
    33  ```
    34  
    35  Please note that the branchName parameter specifies the target branch you want to clone. Also keep in mind that the repositoryName parameter must define a single repository.
    36  
    37  Another option is to read the host and credentials from the cloud foundry service key of the respective instance. Furthermore, if you want to clone multiple repositories, they can be specified in a configuration file.
    38  
    39  With this approach the `config.yml` would look like this:
    40  
    41  ```yaml
    42  steps:
    43    abapEnvironmentCloneGitRepo:
    44      repositories: 'repositories.yml'
    45      cfCredentialsId: 'cfCredentialsId'
    46      cfApiEndpoint: 'https://test.server.com'
    47      cfOrg: 'cfOrg'
    48      cfSpace: 'cfSpace'
    49      cfServiceInstance: 'cfServiceInstance'
    50      cfServiceKeyName: 'cfServiceKeyName'
    51  ```
    52  
    53  and the configuration file `repositories.yml` would look like this:
    54  
    55  ```yaml
    56  repositories:
    57    - name: '/DMO/REPO'
    58      branch: 'main'
    59    - name: '/DMO/REPO_COMMIT'
    60      branch: 'feature'
    61      commitID: 'cd87a3cac2bc946b7629580e58598c3db56a26f8'
    62    - name: '/DMO/REPO_TAG'
    63      branch: 'release'
    64      tag: 'myTag'
    65  ```
    66  
    67  Using such a configuration file is the recommended approach. Please note that you need to use the YAML data structure as in the example above when using the `repositories.yml` config file.
    68  If you want to clone a specific commit, either a `commitID` or a `tag` can be specified. If both are specified, the `tag` will be ignored.
    69  
    70  ## Example: Configuration in the Jenkinsfile
    71  
    72  It is also possible to call the steps - including all parameters - directly in the Jenkinsfile.
    73  In the first example, the host and the credentialsId of the Communication Arrangement are directly provided.
    74  
    75  ```groovy
    76  abapEnvironmentCloneGitRepo (
    77    script: this,
    78    repositoryName: '/DMO/GIT_REPOSITORY',
    79    branchName: 'my-demo-branch',
    80    abapCredentialsId: 'abapCredentialsId',
    81    host: '1234-abcd-5678-efgh-ijk.abap.eu10.hana.ondemand.com'
    82  )
    83  ```
    84  
    85  In the second example, the host and credentialsId will be read from the provided cloud foundry service key of the specified service instance.
    86  
    87  ```groovy
    88  abapEnvironmentCloneGitRepo (
    89    script: this,
    90    repositoryName: '/DMO/GIT_REPOSITORY',
    91    branchName: 'my-demo-branch'
    92    abapCredentialsId: 'cfCredentialsId',
    93    cfApiEndpoint: 'https://test.server.com',
    94    cfOrg: 'cfOrg',
    95    cfSpace: 'cfSpace',
    96    cfServiceInstance: 'cfServiceInstance',
    97    cfServiceKeyName: 'cfServiceKeyName'
    98  )
    99  ```