Integration With GitLab

Applies to TestComplete 15.40, last modified on July 05, 2022

GitLab is a web-based source control system for storing and managing Git repositories. You can run your TestComplete project from this system. For this purpose, use GitLab Runner that works with GitLab CI/CD to run jobs in a pipeline.

The instructions below describe how to run TestComplete projects from GitLab:

  1. Download GitLab Runner matching your Windows operating system version:

  2. Rename the obtained file to gitlab-runner.exe.

  3. Run the command line with administrator permissions and go to the folder where GitLab Runner was downloaded.

  4. Run the following command line to register your runner:

    gitlab-runner.exe register
    Notes:
    • As a GitLab instance URL, specify https://gitlab.com.

    • To obtain the registration token, open Settings > CI/CD > Runners in GitLab. Copy the token in the Specific runners section:

      A registration token for a GitLab Runner

      Click the image to enlarge it.

    • As an executor, specify shell.

  5. Make sure that the GitLab runner has been registered successfully:

    The registered GitLab Runner

    Click the image to enlarge it.

    The specified runner has been added to your current GitLab project.

  6. Install the runner as a service and start it. For these purposes, use the following command lines:

    gitlab-runner.exe install

    gitlab-runner.exe start

  7. To simulate user actions during automated testing, TestComplete must have access to the user interface. In our case, we need to allow the service to interact with the desktop. For that, do one of the following:

    • If you use the Local System account to run the service, select the Allow service to interact with desktop checkbox.

    • Specify the user account that will be used to create an interactive user session.

    Setting a GitLab service

    Click the image to enlarge it.

    For more information about installation and registration of GitLab runners, see the GitLab documentation.

  8. Create a YAML file for your GitLab project. This file will contain a script that launches TestComplete projects from GitLab.

    Choose your project in GitLab and click the New file button:

    Creating a YAML file

    Click the image to enlarge it.

  9. Add the script to the created file. The following example illustrates how you can launch a TestComplete project from GitLab and store test logs:

    YAML

    test-job1:
      stage: test
      tags:
        - tests
      script:
        - cd "c:\Program Files (x86)\SmartBear\TestComplete 15\x64\Bin"
        - echo "This job runs test set 1"
        - .\SessionCreator.exe RunTest /UserName:domain\Tester /password:Password1 /UseActiveSession /ProjectPath:"C:\Users\Tester\Documents\TestComplete 15 Projects\TestProject1\TestProject1.pjs" /ExportLog:"$CI_PROJECT_DIR\logs1\test-results.html
      artifacts:
        paths:
          - $CI_PROJECT_DIR\logs\*.*
      allow_failure: true

    Note: CI_PROJECT_DIR is a predefined GitLab variable that stores the full path the repository is cloned to, and where the job runs from.

See Also

Integration With Source Control Systems
Integration With Continuous Integration (CI) Systems

Highlight search results