Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-17116

graceful job termination

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Major
    • Resolution: Fixed
    • core
    • None
    • any
    • 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

            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.

            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.
            finrodkosh Uwe Teichmann added a comment -

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

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

            finrodkosh 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.

            deepchip Martin d'Anjou added a comment - finrodkosh 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.
            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.
            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.
            owenmehegan Owen Mehegan added a comment -

            deepchip possibly a question for jthompson.

            owenmehegan Owen Mehegan added a comment - deepchip possibly a question for jthompson .

            People

              Unassigned Unassigned
              markusb Markus Breuer
              Votes:
              38 Vote for this issue
              Watchers:
              52 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: