Teamcity agent does not detect powershell core

Answered

I'm not sure about the cause for now but teamcity agent seems to loose powershell Configuration Parameters for powershell_Core and this impact the agent to become incompatible with all build configuration.

I found a fix to restart teamcity agent and the agent is compatible and I see those Configuration Parameters again.

 

  • powershell_Core_7.0.2_x64             7.0.2
   
  • powershell_Core_7.0.2_x64_Path
 C:\Program Files\PowerShell\7
  • powershell_Core_x64
 7.0.2

I had the problem with powershell version 7.0.0, 7.0.1 and 7.0.2.

I use teamcity 2020.1 (build 78475).

0
8 comments

Hi, 

I'm not sure how your build agent can lose an environment parameter if it had the parameter when it initially connected to your TeamCity server. Can you provide some steps to reproduce this issue? Do your teamcity-agent.log files contain any relevant details that you've seen?

Thanks,

Eric

0

Hi,

I have check the logs not sur what is hapenning, i don't see any errors and I have installed last version of teamcity and powershell core 7.0.3.

I have the following environement :

window 2012 R2 64 bits

install teamcity last version

powershell 7.0.3

  1. Create a project and a build step with runner type Powershell
  2. set powershell version 7.0.0
  3. set platform x64
  4. set edition core
  5. Script source: * I use a custom powershell ps1 script. I don't think the probleme is here so you could use any script
  6. script execution execute .ps1 from external file
  7. check add -noprofile
  8. Lauch the build and The teamcity agent does not recognize powershell.

I have the same problem so I have decided to go back and use standard powershell 4+ instead of the recent powershell core 7.

 

 

0

I ran through the steps you listed and it ran successfully. The agent is reporting:

  • powershell_Core_7.0.3_x64 = 7.0.3
  • powershell_Core_7.0.3_x64_Path = C:\Program Files\PowerShell\7
  • powershell_Core_x64 = 7.0.3

But you're saying that these parameters are disappearing after some time, right?

0

Yes, it works for a period of short periode of time (hours or 1-2 days) but than the parameters disapear and the agent can't build anymore because he doesn't respect the powershell requirements.

I didn't pay attention to the periode of time it works. I just realize each time I found the deployment or build not building.

I found that if I restart the agent it works again for a short period of time until it's not working.

Looks like something cause the agent to not find the powershell core variables not sure where to look to give you more informations about what is happening.

0

Do you happen to have the teamcity-agent.log(s) covering the time the agent first connected and reported the correct PS parameters to the time where the PS parameters went missing? This would be a reasonable place to start looking for any clues.

0

Ok,

i found what is causing the problem, looks like the script CommandLinePowerShellDetector use to detect powershell fail with a timeout :

I will enable debug to have more informations next time it's happening.

INFO - Server.powershell.agent.DETECT - Detecting PowerShell using CommandLinePowerShellDetector
Line 62270: [2020-08-30 18:14:05,756] WARN - Server.powershell.agent.DETECT - PowerShell detection script output:
Line 62270: [2020-08-30 18:14:05,756] WARN - Server.powershell.agent.DETECT - PowerShell detection script output:
Line 62272: [2020-08-30 18:14:05,757] WARN - Server.powershell.agent.DETECT - Failed to run PowerShell detection script [C:\TeamCity\buildAgent\system\powershell-runner\detect_1598825625340.ps1] with executable [C:\Program Files\PowerShell\7\pwsh.exe]: com.intellij.execution.ExecutionException: Process execution of ["C:\Program Files\PowerShell\7\pwsh.exe" -NoProfile -File C:\TeamCity\buildAgent\system\powershell-runner\detect_1598825625340.ps1] has timed out. Timeout is set to 20000 msec. (enable debug to see stacktrace)
Line 62272: [2020-08-30 18:14:05,757] WARN - Server.powershell.agent.DETECT - Failed to run PowerShell detection script [C:\TeamCity\buildAgent\system\powershell-runner\detect_1598825625340.ps1] with executable [C:\Program Files\PowerShell\7\pwsh.exe]: com.intellij.execution.ExecutionException: Process execution of ["C:\Program Files\PowerShell\7\pwsh.exe" -NoProfile -File C:\TeamCity\buildAgent\system\powershell-runner\detect_1598825625340.ps1] has timed out. Timeout is set to 20000 msec. (enable debug to see stacktrace)

 

 

0

Ok, after analysis I have reproduce the problem one time when the server restart and the agent start look like that this when the timeout is happening at that moment. On the another test the agent is able to run the script.

So, I have change the agent service to "start delayed" to give windows time to start and I will see if it solve the problem.

 

 

0

There are some instances where the PowerShell detection is inconsistent, maybe this is one of them. You can try adding teamcity.powershell.detector.timeout.msec=<timeout in ms> to the buildAgent.properties file. The default is 20000ms, so you could try increasing it to 40000ms or higher.

This was reported here: https://youtrack.jetbrains.com/issue/TW-64659

0

Please sign in to leave a comment.