Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: core
    • Labels:
      None
    • Environment:
      any
    • Similar Issues:
    • Released As:
      2.141

      Description

      Using the freestyle projects to execute bash shell scripts work fine. But cancelling a jenkins job seems to use SIGKILL. In this way the script cannot perform cleanup operations and free resources.

      SIGKILL cannot be handled by shell

      SIGINT/SIGTERM are not used by jenkins

      Preferred: SIGINT -> wait 5 seconds -> SIGKILL

        Attachments

          Issue Links

            Activity

            Hide
            owenmehegan Owen Mehegan added a comment -

            Martin d'Anjou possibly a question for Jeff Thompson.

            Show
            owenmehegan Owen Mehegan added a comment - Martin d'Anjou possibly a question for Jeff Thompson .
            Hide
            finrodkosh Uwe Teichmann added a comment -

            I'm using Jenkins 2.198 and JRE  jre-1.8.0-openjdk. I created a free style job based on the script by Oliver Smith. The Build Step defined as:

            sudo su - oracle<<eof
            ./shell_signal_handling
            eof
            

            If i cancel the job the process and it's child process get killed correctly, but the console output is:

            Gestartet durch Benutzer Uwe Teichmann
            Running as SYSTEM
            Baue auf dem Agenten „elendil“ (oracle) in Arbeitsbereich /vorlons/jenkins/elendil/workspace/Training/FreeStyle/Shell_Signal_Handling
            [Shell_Signal_Handling] $ /bin/bash -xe /tmp/jenkins10950746844547967776.sh
            + sudo su - oracle
            Sleeping...
            Build wurde abgebrochen
            Abgebrochen von Uwe Teichmann
            Finished: ABORTED
            

            If i change the Build Step to

            sudo su - oracle<<eof
            ./shell_signal_handling 1>./shell_signal_handling.log 2>&1
            eof
            

            the log file contains

            Sleeping...
            Caught signal, cleaning up...
            

            My conclusion: The behaviour is correct, because:

            • The SIGTERM results in the parent process and his childs to stop and exit correctly.
            • The output of the shell script appears in the console job output as long as the connection is active. When killed, the child processes can't send there output anymore to the parent. To see there output we need the log file.
            Show
            finrodkosh Uwe Teichmann added a comment - I'm using Jenkins 2.198 and JRE  jre-1.8.0-openjdk. I created a free style job based on the script by Oliver Smith. The Build Step defined as: sudo su - oracle<<eof ./shell_signal_handling eof If i cancel the job the process and it's child process get killed correctly, but the console output is: Gestartet durch Benutzer Uwe Teichmann Running as SYSTEM Baue auf dem Agenten „elendil“ (oracle) in Arbeitsbereich /vorlons/jenkins/elendil/workspace/Training/FreeStyle/Shell_Signal_Handling [Shell_Signal_Handling] $ /bin/bash -xe /tmp/jenkins10950746844547967776.sh + sudo su - oracle Sleeping... Build wurde abgebrochen Abgebrochen von Uwe Teichmann Finished: ABORTED If i change the Build Step to sudo su - oracle<<eof ./shell_signal_handling 1>./shell_signal_handling.log 2>&1 eof the log file contains Sleeping... Caught signal, cleaning up... My conclusion: The behaviour is correct, because: The SIGTERM results in the parent process and his childs to stop and exit correctly. The output of the shell script appears in the console job output as long as the connection is active. When killed, the child processes can't send there output anymore to the parent. To see there output we need the log file.
            Hide
            deepchip Martin d'Anjou added a comment -

            Uwe Teichmann are you running the job on the master or on a remote node? The problem manifests itself when the job runs on a remote node.

            Show
            deepchip Martin d'Anjou added a comment - Uwe Teichmann are you running the job on the master or on a remote node? The problem manifests itself when the job runs on a remote node.
            Hide
            finrodkosh Uwe Teichmann added a comment -

            The test was done on a local machine, where Jenkins Master and Slave communicate via JNLP.

            Show
            finrodkosh Uwe Teichmann added a comment - The test was done on a local machine, where Jenkins Master and Slave communicate via JNLP.
            Hide
            finrodkosh Uwe Teichmann added a comment -

            At work we use Jenkins 2.138.1. The problem can be reproduced for both freestyle jobs and pipelines. The testcase is performed between two different servers using SLES 12.4, OpenJDP 1.8.0_191-b12.

            Show
            finrodkosh Uwe Teichmann added a comment - At work we use Jenkins 2.138.1. The problem can be reproduced for both freestyle jobs and pipelines. The testcase is performed between two different servers using SLES 12.4, OpenJDP 1.8.0_191-b12.

              People

              • Assignee:
                Unassigned
                Reporter:
                markusb Markus Breuer
              • Votes:
                38 Vote for this issue
                Watchers:
                51 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: