• Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None

      I'm a game developer using Unity.

      My main purpose of using Jenkins is to do some resources check / build / automated test daily.

      I use pipeline to seperate all these steps into continuous stages(no parallel). I call powershell script that is uploaded to svn in the stage and all actual content is inside the script. In the script I'll call regular powershell command/Unity/other exe.

      The weird thing is that occasionally the powershell will hang after Unity exiting successfully, and I checked the Unity's log there is no error. I tried many times running the powershell script directly without Jenkins, it all exited correctly with no hang.

      Powershell commands and other exes are fine, other exes I use are really simple compared to the Unity editor.

      Since this is not a bug that appears every time, I really have no idea how to fix it.

       

      This is the stage that will hang

       

      stage('Build'){
          options{
              timeout(time: 60, unit: "MINUTES")
          }
          steps{
              echo "build start..."
              pwsh("&\"${ScriptPath}/Build.ps1\"")
              echo "build finish"
          }
      }
      

       This is the content inside Build.ps1

      # prepare befor build... 
      Start-Process -FilePath "$UnityEditorPath" -ArgumentList "-batchmode -projectPath ""$ProjectPath"" -nographics -executeMethod CI.Editor.CICalls.DoBuild -buildTarget ""${env:Platform}"" -logfile ""$LogPath"" -quit" -Wait
      # generate report after build...

       I added some echo before and after build so I'm sure when it hangs, the content after build is never executed. And the build is always successful(no error in Unity's log and the result package can be found).

       

       

       

          [JENKINS-63978] Powershell script will hang in pipeline

          Steven Foster added a comment -

          I have this same issue, it's such a head scratcher. It feels like the durable task wrapper script is failing to detect the exit code and write the result text file. I can verify in process explorer that the underlying process has finished and exited. If I manually create the result file in the durable task temp directory, then the step will complete.

          I'm trying to debug and understand the wrapper script some more, it's a bit beyond my experience with powershell.

          Steven Foster added a comment - I have this same issue, it's such a head scratcher. It feels like the durable task wrapper script is failing to detect the exit code and write the result text file. I can verify in process explorer that the underlying process has finished and exited. If I manually create the result file in the durable task temp directory, then the step will complete. I'm trying to debug and understand the wrapper script some more, it's a bit beyond my experience with powershell.

          Preben added a comment - - edited

          We noticed something similar:

          We use pwsh in a scripted pipeline.
          The pwsh process never starts, and the stage/step keeps running, no logs. (Monitored all starting processes pwsh was not in it). Also with a simple step like this, the directory is never created:  

          pwsh "mkdir test"

          Verified on the agent that you can start pwsh and execute the commands this works fine.

           

          The only log line we see in the build output is:
          [Pipeline] pwsh
          Also no error logs in jenkins logs for this plugin, Only:

           

          AgentName seems to be online so using /data/jenkins/workspace/JOBNAME 
          Feb 24, 2025 8:30:10 AM FINE org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep
          still running in /data/jenkins/workspace/JOBNAME on AgentName
          Feb 24, 2025 8:30:11 AM FINER org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep
          launching task against hudson.remoting.Channel@56329123:AgentName using RemoteLauncher[hudson.remoting.Channel@56329123:AgentName]
          Feb 24, 2025 8:35:18 AM FINE org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskSteplaunched task
          Feb 24, 2025 8:35:19 AM FINER org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep

           

          Jenkins version: 2.492.1 

          Plugin version: 1405.v1fcd4a_d00096

          Agent os:  Ubuntu 22.04.1

          Output of $psversiontable on the agent

          PSVersion                      7.5.0
          PSEdition                      Core
          GitCommitId                    7.5.0
          OS                             Ubuntu 22.04.1 LTS
          Platform                       Unix
          PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
          PSRemotingProtocolVersion      2.3
          SerializationVersion           1.1.0.1
          WSManStackVersion              3.0

           

           

          Might also be related to: https://issues.jenkins.io/browse/JENKINS-66048

           

          Rebooting jenkins, or the agent doesn't fix the problem.

          Preben added a comment - - edited We noticed something similar: We use pwsh in a scripted pipeline. The pwsh process never starts, and the stage/step keeps running, no logs. (Monitored all starting processes pwsh was not in it). Also with a simple step like this, the directory is never created:   pwsh "mkdir test" Verified on the agent that you can start pwsh and execute the commands this works fine.   The only log line we see in the build output is: [Pipeline] pwsh Also no error logs in jenkins logs for this plugin, Only:   AgentName seems to be online so using /data/jenkins/workspace/JOBNAME Feb 24, 2025 8:30:10 AM FINE org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep still running in /data/jenkins/workspace/JOBNAME on AgentName Feb 24, 2025 8:30:11 AM FINER org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep launching task against hudson.remoting.Channel@56329123:AgentName using RemoteLauncher[hudson.remoting.Channel@56329123:AgentName] Feb 24, 2025 8:35:18 AM FINE org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskSteplaunched task Feb 24, 2025 8:35:19 AM FINER org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep   Jenkins version: 2.492.1  Plugin version: 1405.v1fcd4a_d00096 Agent os:  Ubuntu 22.04.1 Output of $psversiontable on the agent PSVersion                      7.5.0 PSEdition                      Core GitCommitId                    7.5.0 OS                             Ubuntu 22.04.1 LTS Platform                       Unix PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion      2.3 SerializationVersion           1.1.0.1 WSManStackVersion              3.0     Might also be related to: https://issues.jenkins.io/browse/JENKINS-66048   Rebooting jenkins, or the agent doesn't fix the problem.

          Preben added a comment - - edited

          Found my issue.
          You can solve it by: 

          mv ~/.cache/powershell/StartupProfileData-NonInteractive ~/.cache/powershell/StartupProfileData-NonInteractive.disable 

          https://github.com/PowerShell/PowerShell/issues/18998#issuecomment-1632780598 

           

          Strange that the jenkins plugin doesn't propagate the error message of pwsh
          When executing pwsh from bash with -c you get the following:

          pwsh -c "Hello"
          Segmentation fault (core dumped) 

           

          If you just run pwsh, everything worked.

          Preben added a comment - - edited Found my issue. You can solve it by:  mv ~/.cache/powershell/StartupProfileData-NonInteractive ~/.cache/powershell/StartupProfileData-NonInteractive.disable https://github.com/PowerShell/PowerShell/issues/18998#issuecomment-1632780598     Strange that the jenkins plugin doesn't propagate the error message of pwsh When executing pwsh from bash with -c you get the following: pwsh -c "Hello" Segmentation fault (core dumped)   If you just run pwsh, everything worked.

            Unassigned Unassigned
            axelhu Axel Hu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: