gfoidl / trx2junit

Transforms XML from trx-Testresults to JUnit-Testresults / trx to JUnit XML and the other way round
MIT License
70 stars 17 forks source link

The term 'trx2junit' is not recognized as the name of a cmdlet, function, script file, or operable program #96

Closed capalmeida closed 2 years ago

capalmeida commented 2 years ago

I'm trying to setup the trx2junit in circleci but can't get it to work, so far my relevant code is:

# ...

- run:
     name: "Run Application Tests"
     command: dotnet test --no-build --logger "trx" --results-directory tests/output
 - run:
    name: "Collect Test Results"
     when: always
     command: |
        dotnet tool install -g trx2junit
        echo 'export PATH="$PATH:/root/.dotnet/tools"' >> "$BASH_ENV"
        trx2junit tests/output/*.trx --output tests/TestResults

Error from circleci:

 Since you just installed the .NET SDK, you will need to reopen the Command Prompt window before running the tool       you installed.
 You can invoke the tool using the following command: trx2junit
 Tool 'trx2junit' (version '2.0.0') was successfully installed.
 trx2junit : The term 'trx2junit' is not recognized as the name of a cmdlet, function, script file, or operable 
 program. Check the spelling of the name, or if a path was included, verify that the path is correct and try  again.
 At line:3 char:1

Any ideas on how I can overcome this? Also this started as we're setting up .NET 6 in our build pipelines, until then the following code worked without a problem:

 - run:
     name: "Collect Test Results"
     when: always
     command: |
        dotnet tool install -g trx2junit
        trx2junit tests/output/*.trx --output tests/TestResults
gfoidl commented 2 years ago

With echo 'export PATH="$PATH:/root/.dotnet/tools"' >> "$BASH_ENV" you append the $PATH, but the shell doesn't get informed by that update automatically. So you have a few options:

Can you give one option a try and see if it works? Unfortunately this problem isn't (directly) related to trx2junit, as there was no change in that area. So it's either CircleCI or .NET SDK -- but I believe it just worked before by accident, as that behavior is documented at CircleCI and conforms POSIX behavior.

capalmeida commented 2 years ago

Unfortunately I've tried already both suggestions, first by starting the new shell-environment, and the second removing the echo command, Both failed. But re-tried again to make sure of the results:

The first suggestion yields the same error:

 trx2junit : The term 'trx2junit' is not recognized as the name of a cmdlet, function, script file, or operable 
 program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
 At line:1 char:

And the second generates a different error:

 At line:2 char:14
 + export PATH="$PATH:/root/.dotnet/tools"
 +              ~~~~~~
 Variable reference is not valid. ':' was not followed by a valid variable name character. Consider using ${} to 
 delimit the name

Regarding the second one, although it is the recommended code in CircleCI documentation (https://circleci.com/docs/2.0/collect-test-data/#dot-net) it fails. Maybe that's why the trx2junit readme was updated with the info:

  Check also the documentation of your CI-system on how to persist the PATH between steps, etc. 
  E.g. in         CircleCI you need to run
  echo 'export PATH="$PATH:/root/.dotnet/tools"' >> "$BASH_ENV"
gfoidl commented 2 years ago

Can you SSH into the CircleCI build (via their app, re-run workflow with SSH) and see what's going on?

Sorry that I can't help more here, as I don't use CircleCI (anymore) and that problem is caused either by an update from CircleCIs shell, the .NET docker image or something else. But with SSHing into the build (one of the 👍🏻 of CircleCI) you can inspect the environment, fix it there and port that change back the the config.yml.

I hope that you'll be able to find a solution.

gfoidl commented 2 years ago

Closing as not actionable here -- it's an external issue.

If the issue is indeed related to trx2junit, please feel free to leave a comment / re-open.