Luis Angel Urena Lopez
Luis Angel Urena Lopez

Reputation: 389

How to run an executable file in GitLab CI/CD script using powershell

I'm stuck in what seems to be a basic thing. I'm trying to run conan.exe which is located in C:\Program Files (x86)\Conan\conan\conan.exe. The errors I get are either

.\C:\Program Files (x86)\Conan\conan\conan.exe : The term '.\C:\Program Files (x86)\Conan\conan\conan.exe' 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:1
+ .\"C:\Program Files` (x86)\Conan\conan\conan.exe"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (.\C:\Program Fi...conan\conan.exe:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

or

x86 : The term 'x86' 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:22
+ .\C:\Program Files` (x86)\Conan\conan\conan.exe
+                      ~~~
    + CategoryInfo          : ObjectNotFound: (x86:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

I've tried a combination of ", ', using ` for spaces, using & at the start (doesn't work since it's reserved for GitLab Runner). I'm out of ideas and my google searches don't seem to help specifically for gitlab ci/cd context.

This is the latest .gitlab-ci.yml I tried:

stages:
    - build
    - publish

test_build:
    stage: build
    script:
        - \& "C:\Program Files (x86)\Conan\conan\conan.exe"
    tags:
        - build

With this error:

At C:\WINDOWS\TEMP\build_script663599467\script.ps1:229 char:2
+ \& "C:\Program Files (x86)\Conan\conan\conan.exe"
+  ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double 
quotation marks ("&") to pass it as part of a string.
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : AmpersandNotAllowed
 
Cleaning up file based variables
00:01
ERROR: Job failed: exit status 1

Anyone has any idea what could work?

Upvotes: 3

Views: 7491

Answers (1)

Aan Dahliansyah
Aan Dahliansyah

Reputation: 123

Here Is the answer. In short:

script:
    - 'powershell.exe D:\app\CiTest.exe'

While CiTest.exe is a dotnet framework 4.8 console application.

Upvotes: 0

Related Questions