From 263f0d8e76dcd400540a4e3d2e5be2af55a21cea Mon Sep 17 00:00:00 2001 From: Sophie Depassio Date: Tue, 10 Dec 2024 16:30:32 +0100 Subject: [PATCH] log error message only for true error --- .github/workflows/test-cpan-libraries.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-cpan-libraries.yml b/.github/workflows/test-cpan-libraries.yml index 80a40f300e..9c42f975ed 100644 --- a/.github/workflows/test-cpan-libraries.yml +++ b/.github/workflows/test-cpan-libraries.yml @@ -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 @@ -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 @@ -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