Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not getting the output from shell script in Gitlab CI

Tags:

shell

gitlab

I have set up a gitlab runner on my windows. I have a build.sh script in which I am just echoing "Hello world". I have provided these lines in my gitlab-ci.yml file:

build:
    stage: build
    script:
        - ./build.sh

The runner executes this job but does not print the echo command which I have mentioned in the build.sh file. But if I changed the extension to .bat it works and shows me the output. The gitlab-runner is set up for shell. What can be the possible reason? or I am missing something?

like image 940
deanavenger Avatar asked May 27 '26 02:05

deanavenger


1 Answers

GitLab will output for anything that ends up written to STDOUT or STDERR. It's hard to say what's happening without seeing your whole script, but I imagine somehow you're not actually echoing to STDOUT. This is why the output isn't ending up in the CI output.

To test this I created a test project on GitLab.com. One difference in my test is my CI YAML script command was sh build.sh. This is because the script wasn't executable so it couldn't be executed with ./build.sh.

builds.sh file:

#!/bin/bash

echo "This is output from build.sh"

.gitlab-ci.yml file:

build:
  stage: build
  script:
    - sh build.sh

The build output:

Running with gitlab-runner 12.3.0-rc1 (afb9fab4)
  on docker-auto-scale 72989761
...
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/dblessing/ci-output-test/.git/
Created fresh repository.
Checking out cfe8a4ee as master...

Skipping Git submodules setup

$ sh build.sh
This is output from build.sh
Job succeeded
like image 103
Drew Blessing Avatar answered May 31 '26 16:05

Drew Blessing



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!