Skip to content

Commit

Permalink
log error message only for true error
Browse files Browse the repository at this point in the history
  • Loading branch information
sdepassio committed Dec 10, 2024
1 parent bf490ab commit 263f0d8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/test-cpan-libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ jobs:
# Add Centreon plugins repositories
echo -e '[centreon-plugins-stable]\nname=centreon plugins stable x86_64\nbaseurl=https://packages.centreon.com/rpm-plugins/${{ matrix.distrib }}/stable/x86_64\nenabled=1\ngpgcheck=1\ngpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n[centreon-plugins-stable-noarch]\nname=centreon plugins stable noarch\nbaseurl=https://packages.centreon.com/rpm-plugins/${{ matrix.distrib }}/stable/noarch\nenabled=1\ngpgcheck=1\ngpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n' >> /etc/yum.repos.d/centreon-plugins.repo
else
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y zstd perl wget gpg apt-utils
# Add Centreon plugins repositories
Expand Down Expand Up @@ -477,13 +478,13 @@ jobs:
for dependency in $dependencies; do
# If the dependency has been built in the same workflow, install it
if [ -f $dependency*.rpm ]; then
dnf install -y $dependency*.rpm 2>> $error_log || { echo "Error during installation of $package" >> $error_log; true; }
error_output=$(dnf install -y $dependency*.rpm 2>&1) || { echo "$error_output" >> $error_log; echo "Error during installation of $dependency" >> $error_log; true; }
fi
done
# Install package
dnf install -y $package 2>> $error_log || { echo "Error during installation of $package" >> $error_log; true; }
error_output=$(dnf install -y $package 2>&1) || { echo "$error_output" >> $error_log; echo "Error during installation of $package" >> $error_log; true; }
# Uninstall package with all his dependencies
dnf autoremove -y $(echo $package | sed 's/_[0-9].*\.rpm//' | sed 's/.\///') 2>> $error_log || true
error_output=$(dnf autoremove -y $(echo $package | sed 's/_[0-9].*\.rpm//' | sed 's/.\///') 2>&1) || { echo "$error_output" >> $error_log; echo "Error during autoremove of $package" >> $error_log; true; }
done
# Si le fichier error_log existe et n'est pas vide, le workflow est en erreur
if [ -s $error_log ]; then
Expand All @@ -501,14 +502,14 @@ jobs:
for dependency in $dependencies; do
# If the dependency has been built in the same workflow, install it
if [ -f $dependency*.deb ]; then
apt-get install -y $dependency*.deb 2>> $error_log || { echo "Error during installation of $package" >> $error_log; true; }
error_output=$(apt-get install -y $dependency*.deb 2>&1) || { echo "$error_output" >> $error_log; echo "Error during installation of $dependency" >> $error_log; true; }
fi
done
# Install package
apt-get install -y $package 2>> $error_log || { echo "Error during installation of $package" >> $error_log; true; }
error_output=$(apt-get install -y $package 2>&1) || { echo "$error_output" >> $error_log; echo "Error during installation of $package" >> $error_log; true; }
# Uninstall package with all his dependencies
# Package name is the name of the file less the version and the .deb extension, and without the "./" at the beginning
apt-get autoremove -y --purge $(echo $package | sed 's/_[0-9].*\.deb//' | sed 's/.\///') 2>> $error_log || true
error_output=$(apt-get autoremove -y --purge $(echo $package | sed 's/_[0-9].*\.deb//' | sed 's/.\///') 2>&1) || { echo "$error_output" >> $error_log; echo "Error during autoremove of $package" >> $error_log; true; }
done
# Si le fichier error_log existe et n'est pas vide, le workflow est en erreur
if [ -s $error_log ]; then
Expand Down

0 comments on commit 263f0d8

Please sign in to comment.