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

Pipeline kill process successfully but grep command still find the process

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Unresolved
    • Icon: Major Major
    • pipeline
    • None

      Hello 

      When I run pipeline with sh to kill a process on linux server, but when I run "ps -ef | grep XXX" this process it is still there.

      Could you help to guide me how to make it work please?

      For example:
      node('my_linux_server'){
         stage('Stop Jenkins'){
              echo "Stop Jenkins Server " + env.JENKINS_SERVER_NAME
              sh 'kill `pgrep -f ${JENKINS_SERVER_NAME}`'
              sh 'ps -ef | grep -v grep | grep $JENKINS_SERVER_NAME'
         }
      }

      actually, the process is doesn't exsit when run "kill `pgrep -f ${JENKINS_SERVER_NAME}`", the second command "ps -ef | grep -v grep | grep $JENKINS_SERVER_NAME" shouldn't return any thing, but it did.

       

      So could you help to have a look it if it is a issue or something wrong with my commands please?

       

       

            Unassigned Unassigned
            benjaminas2014 Guo Zhihui
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: