9

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?

1 Answer 1

6

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
Sign up to request clarification or add additional context in comments.

2 Comments

Is it possible in gitlab CI to print every shell command that is being executed, like Jenkins does?
GitLab will show all commands that are specified within the .gitlab-ci.yml directly. This is shown as $ sh build.sh in the output example above. GitLab will not show what's going on within a given script file, though. Although I don't know for sure, I would be surprised in Jenkins does, either. A script could choose to manually print commands or output as relevant, and GitLab will show those in the build trace.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.