Jenkins kill all child processes

后端 未结 1 484
予麋鹿
予麋鹿 2020-12-30 04:15

I have a jenkins job that runs a bash script.

In the bash script I perform effectively two actions, something like

java ApplicationA &
PID_A=$!
j         


        
1条回答
  •  时光说笑
    2020-12-30 04:43

    Actually, by default, Jenkins has a feature called ProcessTreeKiller which is responsible to make sure there are no processes left running after the job execution.

    The link above explain how to disable that feature. Are you sure you don't have that disabled by mistake somehow?

    Edit:
    Following the comments by the author, based on the information about disabling ProcessTreeKiller, to achieve the inverse one must set the environment variable BUILD_ID to the build id of Jenkins job. This way, when ProcessTreeKiller looks through the running processes to kill, it will find this as well

    export BUILD_ID=$BUILD_ID

    You can also use the Build Result Trigger plugin, configure a second job to clean up your applications, and configure it to monitor the first job for ABORTED state as a trigger.

    0 讨论(0)
提交回复
热议问题