Run build step failed with subshell on CircleCI which it is hard coded to exit 0

circle.yml

#1

Hello,

I have a build step like this

   - run:
       name: Hello
       command: |
          (
            command_1
            command_2
          )

On CircleCI, it is just simply saying: Exited with code 1

I have few similar builds before it which running under subshell too and they still work fine. I tried to SSH into the CircleCI and execute above subshell, I got the exit code is 0

Inside command_2, I added return 0. There is no error with any command inside that script.

Any advice would be appreciated so much :frowning:

Thanks.


#2

Don’t you need to separate those commands with && or ;?


#3

command_1 will change directory, command_2 is a shell script. In previous subshells, I use exactly same thing, cd and shell script, but the exit-code is 0 for them


#4

What is the actual, full, real command?


#5

something like

(
  cd path/to/directory
  ./the-script.sh
)

I use exactly same as above after SSH and $? is 0.


#6

OK. What’s the purpose of the subshell here? Can you remove the brackets?


#7

I don’t want to change the current working directory, then have to use cd -. But is there any reason if previous ones still working?


#8

Gotcha. Well, I’d suggest you get it working first :smile_cat:. You can also preserve the dir using:

CURRENT_DIR=`pwd`

Or, alternatively, can you modify the script so that it takes a dir/file parameter? That is generally better than needing to be in a specific cwd anyway.


#9

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.