Forum Discussion

Petewilson's avatar
Petewilson
Contributor
17 days ago
Solved

Pulling Test Data from a GitLab Repo

At the start of the test i have a data that is pulled from various sources to build the correct environment with the latest exes and data.

I have the lastest exes copied from a network location successfully but I have a GitLab repo that the client updates and i am struggling to get TestComplete to connect to the Repo and pull down. Are there any examples for pulling down from a GitLab repo to a local machine drive.

All examples i can find refer to TestComplete and it's inbuilt option for pulling down the latest test pack but not a method for pulling down test environment data.

Any pointers in the right direction would be appreciated.

  • I would design my pipeline to either pull down from source code repository or from network share all related pieces (automation project, data, binaries, etc...) to set up the environment, than when ready I would execute my automation run.

    If I understand it correctly, you are trying to have TestComplete project during the test run pull down data from GitLab and copy binaries from network drive. In that case you can achieve this using a git clone or git pull command. I have not tried the bellow example.

    function PullFromGitLab() {
      // Create a shell object to run command line operations
      var shell = Sys.OleObject("WScript.Shell");
      
      // Define the local path where the repo should live
      var repoPath = "C:\\TestEnv\\DataRepo";
    
      // Check if the folder exists
      if (aqFileSystem.Exists(repoPath)) {
        // If it does, navigate there and run git pull
        var pullCmd = 'cmd.exe /C cd /d "' + repoPath + '" && git pull';
        Log.Message("Running: " + pullCmd);
        shell.Run(pullCmd, 0, true);
      } else {
        // If not, clone the repo into that directory
        var gitUrl = "https://gitlab.com/yourgroup/yourrepo.git";  // Replace with your actual repo URL
        var cloneCmd = 'cmd.exe /C git clone "' + gitUrl + '" "' + repoPath + '"';
        Log.Message("Running: " + cloneCmd);
        shell.Run(cloneCmd, 0, true);
      }
    }
    

    Note: on the agent or VM, per-configure Git and authentication. Also make sure you're using an HTTPS URL with a personal access token (PAT),
    example: https://oauth2:YOUR_TOKEN@gitlab.com/yourgroup/yourrepo.git

    P.S. if you like my post give a like, and if it solves your problem mark it as a solution.

5 Replies

  • Hassan_Ballan's avatar
    Hassan_Ballan
    Icon for Champion Level 1 rankChampion Level 1

    I would design my pipeline to either pull down from source code repository or from network share all related pieces (automation project, data, binaries, etc...) to set up the environment, than when ready I would execute my automation run.

    If I understand it correctly, you are trying to have TestComplete project during the test run pull down data from GitLab and copy binaries from network drive. In that case you can achieve this using a git clone or git pull command. I have not tried the bellow example.

    function PullFromGitLab() {
      // Create a shell object to run command line operations
      var shell = Sys.OleObject("WScript.Shell");
      
      // Define the local path where the repo should live
      var repoPath = "C:\\TestEnv\\DataRepo";
    
      // Check if the folder exists
      if (aqFileSystem.Exists(repoPath)) {
        // If it does, navigate there and run git pull
        var pullCmd = 'cmd.exe /C cd /d "' + repoPath + '" && git pull';
        Log.Message("Running: " + pullCmd);
        shell.Run(pullCmd, 0, true);
      } else {
        // If not, clone the repo into that directory
        var gitUrl = "https://gitlab.com/yourgroup/yourrepo.git";  // Replace with your actual repo URL
        var cloneCmd = 'cmd.exe /C git clone "' + gitUrl + '" "' + repoPath + '"';
        Log.Message("Running: " + cloneCmd);
        shell.Run(cloneCmd, 0, true);
      }
    }
    

    Note: on the agent or VM, per-configure Git and authentication. Also make sure you're using an HTTPS URL with a personal access token (PAT),
    example: https://oauth2:YOUR_TOKEN@gitlab.com/yourgroup/yourrepo.git

    P.S. if you like my post give a like, and if it solves your problem mark it as a solution.

    • Petewilson's avatar
      Petewilson
      Contributor

      That's exactly it. My issue was that i have automated tests that are run from Jenkins, which can build all the environment as i need it, but i have some users that want to run standalone or don't have access to Jenkins. Having it all handled in TestComplete for those uses means they always have the correct, most up to date data when running just TestComplete standalone.

  • Morning rraghvani,

    No i have the project already pulled down, when the project runs, Once the TestComplete Suite runs the script needs to pull the test data down from a GitLab Repo and put in a folder, then copy the Test Exe files over the top of that and run the application to test. It's the pull down from the GitLab Repo i'm struggling with.

    If TestComplete can't be scripted to pull down the Test Environment Data repo i'll do it via Jenkins, which is how the TestComplete project is pulled down initially.

    • rraghvani's avatar
      rraghvani
      Icon for Champion Level 3 rankChampion Level 3

      I’m struggling to understand here.

      In TestComplete, you have Source Control, which works with Git, Microsoft Team Foundation Version Control, CollabNet Subversion and Mercurial. See Integration With Source Control Systems for more information.

      Then you have GitLab, which is a web-based source control system for storing and managing Git repositories (similar to Azure DevOps).

      You have GitLab Runner that works with GitLab CI/CD to run jobs in a pipeline (similar to Azure Pipeline). The pipeline, once it has been registered and correctly configured, will download the necessary files from your Git repository, launch TestComplete/Execute and run the automation and provide results.

      However, to download the repository to your local machine, see https://docs.gitlab.com/user/project/repository/ - you want to clone the repository. Either use Source Control Git plugin within TestComplete or GitLab web (outside of TestComplete). I'm not aware this can be scripted within TestComplete.

       

  • rraghvani's avatar
    rraghvani
    Icon for Champion Level 3 rankChampion Level 3

    Are you referring to the TestComplete Project, which you are trying to download from the repository to your local machine?