Associated community ticket: https://github.community/t/no-output-on-process-completed-with-exit-code-1/123821
In this ticket, the customer has a run step to execute some command lines in the container job (image: centos:7).
One of the command lines is calling a .sh script file (see here). But this command line failed and returned the error message like as below:
##[error]Process completed with exit code 1.
The customer enabled the debug logging to try get more information about this error, but the debug logs seem were not helpful. It still only returned the same one error message.
According to my troubleshooting, the error seems was returned by a certain command line in the called .sh script.
The customer also run the same type workflow on Ubuntu 18.04, 20.04, and on macOS, but without any failures there.
And he just tried running the exact same commands in the same CentOS docker container that the failing workflow is using, and I cannot reproduce the error.
Issue:
https://github.community/t/no-output-on-process-completed-with-exit-code-1/123821/9
##[error]Process completed with exit code 1.
Fix:
. scl_source enable llvm-toolset-6.0 || true
or
. $INSTALL_DIR/bin/thisbdm.sh replace to $INSTALL_DIR/bin/thisbdm.sh
Explanation:
- name: System tests BioDynaMo
shell: bash
working-directory: build
run: |
set -x
Line:
2020-07-23T11:30:35.2865130Z +++ /usr/bin/scl_enabled llvm-toolset-6.0
2020-07-23T11:30:35.3275453Z ##[error]Process completed with exit code 1.
I found out which part of code is executing this line:
. scl_source enable llvm-toolset-6.0scl_source code# Now check if the collection isn't already enabled
/usr/bin/scl_enabled $arg > /dev/null 2> /dev/null <- failed line
if [ $? -ne 0 ]; then
for _scls+=($arg)
_scl_prefixes+=($_scl_prefix)
fi;
done
Fix:
run: |
. scl_source enable devtoolset-7 || true
. scl_source enable llvm-toolset-6.0 || true
. /etc/profile.d/modules.sh || true
module load mpi
. $INSTALL_DIR/bin/thisbdm.sh
git config --system user.name "Test User"
git config --system user.email [email protected]
xvfb-run -d -s "-screen 0 2560x1440x24" make run-demos

@senui,
Case with source:
The /usr/bin/scl_enabled llvm-toolset-6.0 encounters a exit 1 which is different from zero. It will terminate the scl_source code instantaneously due to the exit statement and that's why:
. $INSTALL_DIR/bin/thisbdm.sh - failed and $INSTALL_DIR/bin/thisbdm.sh - works
Looks like it by design:
return [n]
Causes a function to exit with the return value specified by n. If used outside a function, but during execution of a script by the . (source) command, it causes the shell to stop executing that script and return either n or the exit status of the last command executed within the script as the exit status of the script. If used outside a function and not during execution of a script by ., the return status is false.
source filename [arguments]
Read and execute commands from filename in the current shell environment and
return **the exit status of the last command executed from filename**.
Reproduce behavior:
Without source( ./test.sh):
steps:
- name: Test
run: |
cat <<EOF > $HOME/subscript.sh
#!/bin/sh
exit 1
EOF
chmod +x $HOME/subscript.sh
cat <<EOF > test.sh
#!/bin/bash
$HOME/subscript.sh
if [ $? -ne 0 ]; then
echo PASS
fi;
EOF
chmod +x ./test.sh
echo START
./test.sh
echo END

With source(source ./test.sh):
steps:
- name: Test
run: |
cat <<EOF > $HOME/subscript.sh
#!/bin/sh
exit 1
EOF
chmod +x $HOME/subscript.sh
cat <<EOF > test.sh
#!/bin/bash
$HOME/subscript.sh
if [ $? -ne 0 ]; then
echo PASS
fi;
EOF
chmod +x ./test.sh
echo START
source ./test.sh
echo END

With source || true (source ./test.sh || true):
steps:
- name: Test
run: |
cat <<EOF > $HOME/subscript.sh
#!/bin/sh
exit 1
EOF
chmod +x $HOME/subscript.sh
cat <<EOF > test.sh
#!/bin/bash
$HOME/subscript.sh
if [ $? -ne 0 ]; then
echo PASS
fi;
EOF
chmod +x ./test.sh
echo START
source ./test.sh || true
echo END

Most helpful comment
Issue:
https://github.community/t/no-output-on-process-completed-with-exit-code-1/123821/9
##[error]Process completed with exit code 1.Fix:
. scl_source enable llvm-toolset-6.0 || trueor
. $INSTALL_DIR/bin/thisbdm.shreplace to$INSTALL_DIR/bin/thisbdm.shExplanation:
Line:
I found out which part of code is executing this line:
. scl_source enable llvm-toolset-6.0scl_sourcecodeFix:
@senui,
Case with source:
The
/usr/bin/scl_enabled llvm-toolset-6.0encounters aexit 1which is different from zero. It will terminate thescl_source codeinstantaneously due to theexitstatement and that's why:. $INSTALL_DIR/bin/thisbdm.sh- failed and$INSTALL_DIR/bin/thisbdm.sh- worksLooks like it by design:
https://askubuntu.com/questions/182012/is-there-a-difference-between-and-source-in-bash-after-all?lq=1
Reproduce behavior:
Without source( ./test.sh):
With source(source ./test.sh):
With source || true (source ./test.sh || true):