Forum Discussion

kakabubu's avatar
kakabubu
Contributor
8 months ago
Solved

Azure pipline yaml cancel TC run

GIVEN
azure devops yaml file pipeline devided on two jobs
firstJob - some tasks preparing environment, install last version, etc
secondJob - some more preparations tasks and run tests task
Test run task is a runTests.ps1 script wich run the "C:\Program Files \...\TestComplete.exe" with parametrs (desired project, etc)
WHEN  I cancel the build
THEN I want testcomplete to stop running the tests

But I cant figure out how make test complete (running on pool agent) know that he should make Runner.Stop(false)
I'm thinking to read from file in the project sources folder, but how can i write to that file from pipelines when build cancels
Did anyone solved the similar problem? 

  • kakabubu's avatar
    kakabubu
    7 months ago

    The actual problem was with jobs conditions.

    I've added the "and(succeededOrFailed() , ..." and now TC is stopped when the pipeline is canceled.
    The only nuance is that my AfterTests operations are not performed. But that is acceptable for the scenarios in which I will cancel that pipeline.

2 Replies

  • Gracegoods's avatar
    Gracegoods
    Occasional Visitor

    kakabubu wrote:

    GIVEN
    azure devops yaml file pipeline devided on two jobs
    firstJob - some tasks preparing environment, install last version, etc
    secondJob - some more preparations tasks and run tests task
    Test run task is a runTests.ps1 script wich run the "C:\Program Files \...\TestComplete.exe" with parametrs (desired project, etc)
    WHEN  I cancel the build
    THEN I want testcomplete to stop running the tests

    But I cant figure out how make test complete (running on pool agent) know that he should make Runner.Stop(false)
    I'm thinking to read from file in the project sources folder, but how can i write to that file from pipelines when build cancels
    Did anyone solved the similar problem?   CafeRioListens


    Hello,

     

    One approach to solve this problem is to use a shared resource, such as a file, to communicate between the pipeline and the TestComplete script. You can create a file in your project's source folder and have the TestComplete script continuously monitor the file for any changes. In your pipeline, when you cancel the build, you can write a specific value to the file, indicating that the tests should be stopped.

     

    The TestComplete script can then read this value from the file and execute the `Runner.Stop(false)` command accordingly. To write to the file from the pipeline, you can use a script task that runs a command-line utility or a custom script that updates the file with the desired value.

     

    I hope the information you like it. 

     

     

     

     

     

     

    • kakabubu's avatar
      kakabubu
      Contributor

      The actual problem was with jobs conditions.

      I've added the "and(succeededOrFailed() , ..." and now TC is stopped when the pipeline is canceled.
      The only nuance is that my AfterTests operations are not performed. But that is acceptable for the scenarios in which I will cancel that pipeline.