Before_script run shell script

Hello,

we use gitlab runner on a windows machine.
When I use the following simple ci.yaml:

before_script:
  - echo Before Script

after_script:
  - echo After Script

stages:
  - build
  - test
 
build:
  stage: build
  script:
    - echo Build Master

test:
  stage: test
  script:
    - echo testing

The output is:
Checking out 8bb48e61 as master…
Skipping Git submodules setup
echo Before Script Before Script echo Build Master
Build Master
Running after script…
$ echo After Script
After Script
Job succeeded

The order of the ci run is:

  • before_script
  • build
  • test
  • after_script

But when I run a shell script in the before_script (*.cmd on Windows)
the after_script is immediately executed after the before_script and the other steps are skipped
completely.
Example ci.yaml:

 before_script:
      - echo Before Script
      - hello.cmd #contains: echo Hello World

    after_script:
      - echo After Script

    stages:
      - build
      - test
     
    build:
      stage: build
      script:
        - echo Build Master

    test:
      stage: test
      script:
        - echo testing

the Output is:
Checking out f712fa9d as master…
Skipping Git submodules setup
echo Before Script Before Script hello.cmd
Hello World
Running after script…
$ echo After Script
After Script
Job succeeded

Only before_script and after_script are run. The other steps (build and test) are missing.
So how can I run a shell script (*.bat or *.cmd) in the before_script?

Thanks for your help.
Andy

Hi, Avl

I’m having the same issue.
have you found a solution?
oppened a bug for this : https://gitlab.com/gitlab-org/gitlab/issues/192174

Fixed this by adding “call” to batch file e.g - call myFile.bat