teamcity-docker-minimal-agent icon indicating copy to clipboard operation
teamcity-docker-minimal-agent copied to clipboard

Powershell environment variables not set correctly?

Open vyruz1986 opened this issue 6 years ago • 16 comments

When using this image (or the regular jetbrains/teamcity-agent image for the same matter), both the windows and linux flavors have powershell core installed (pwsh.exe on windows or pwsh on linux starts a powershell prompt), but when trying to configure a build with a powershell build step in it, the build says that an agent based on this image is not compable due to the following missing requirement:

Unmet requirements: 
Exists=>(powershell_Core_x86|powershell_Core_x64|powershell_Desktop_x86|powershell_Desktop_x64) exists

Looking at my standard on-prem windows-based build agents, they do have several powershell_... parameters listed when looking at > Agent Parameters > Configuration Parameters. But it's unclear to me how those parameters are defined... I have powershell on my workstation as well, but I don't see those parameters when I run Get-Variable in powershell, so are these being set by the Teamcity agent on first run, or...?

vyruz1986 avatar Jan 28 '19 14:01 vyruz1986

I'll vote this up. I am experiencing exactly the same issue.

domingoladron avatar Jul 23 '19 03:07 domingoladron

Which TeamCity version do you have? Issues with PowerShell detection have been fixed in recent versions (2019.1 for sure). Please not that plugin version on the agent depends on the server's version.

JuliaResh avatar Jul 23 '19 09:07 JuliaResh

I am running the ubuntu teamcity-docker-server (2019.1.1) & teamcity-docker-agent and seeing this same issue.

thomaswdean avatar Jul 25 '19 19:07 thomaswdean

Thanks for the reply. I'm using the most recent versions of your docker server and agent.

On Tue, Jul 23, 2019, 21:45 Julia Reshetnikova [email protected] wrote:

Which TeamCity version do you have? Issues with PowerShell detection have been fixed in recent versions (2019.1 for sure). Please not that plugin version on the agent depends on the server's version.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/JetBrains/teamcity-docker-minimal-agent/issues/31?email_source=notifications&email_token=AGX2IH5ZIH345HT2Z4MNJ7DQA3HJXA5CNFSM4GSYJRM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2SRVIQ#issuecomment-514136738, or mute the thread https://github.com/notifications/unsubscribe-auth/AGX2IH2WJO6HRSV7YTWSULLQA3HJXANCNFSM4GSYJRMQ .

domingoladron avatar Jul 25 '19 20:07 domingoladron

What is the status of this issue? We are running ubuntu docker image teamcity-docker-server 2019.2 (build 71499) and are suddenly seeing the issue. The (win) agents is running win docker image teamcity-minimal-agent:latest-nanoserver-sac2016.

Could the fact that we still use sac2016 make a difference?

hulvei3 avatar Feb 17 '20 08:02 hulvei3

I am also experiencing this issue all of a sudden. I can't seem to find any documentation on how to configure the container to know that it has powershell installed. Pls help.

sjauld avatar Mar 31 '20 09:03 sjauld

@hulvei3 @sjauld Could you please file an issue in the TeamCity issue tracker: https://youtrack.jetbrains.com/issues/TW? Could you please add information on which tag do use and attach 'teamcity-agent.log' with debug level turned on covering the time of the agent restart?

JuliaResh avatar Apr 01 '20 16:04 JuliaResh

I also am having this issue. I downloaded the latest of both the regular agent and minimal agent for linux (ubuntu). I'm using docker for windows and did a cli to the both agents and neither has powershell installed by default. Using the TC server instance (also a container), I got to the agent log and found this:

[2020-04-01 12:55:21,209] INFO - Server.powershell.agent.DETECT - No PowerShell detected. If it is installed in non-standard location, please provide install locations in teamcity.powershell.detector.search.paths agent property (with ';' as a separator) [2020-04-01 12:55:21,252] INFO - .agent.AgentStartupGitDetector - Detect git at /usr/bin/git [2020-04-01 12:55:21,263] WARN - r.mono.MonoPropertiesExtension - Failed to start pkg-config. Cannot run program "pkg-config": error=2, No such file or directory

I've attached the log teamcity-agent.log

stevekumbsky avatar Apr 01 '20 20:04 stevekumbsky

We are having the same problem as of now. We are on version 2019.2 and the only difference was our security team installed Windows Updates on the Windows Server 2016 core host.

I can see and use powershell inside the container so seems an issue with the Server.powershell.agent.DETECT

ricohomewood avatar Apr 02 '20 10:04 ricohomewood

@stevekumbsky Ubuntu based images (both teamcity-agent and teamcity-minimal-agent) do not have PowerShell installed.

JuliaResh avatar Apr 06 '20 11:04 JuliaResh

@JuliaResh - I apologize that my initial post did not include that I did install powershell core and made sure the install folder to powershell was included the PATH and that I could run pwsh. I got the same warnings in the log after doing all this. I will attempt again to install powershell core and restart all instances to see of the Build configuration on my TC server picks up that the Agent detects powershell. I will also try out the Windows container.

Also @ricohomewood mentioned that he can see and use powershell in their agent containers and still has this issue.

stevekumbsky avatar Apr 07 '20 11:04 stevekumbsky

@stevekumbsky Thank you for the details. To detect installed PowerShell Core build agent searches the file system in the pre-configured paths (so the PATH variable is not involved). Could you please share the location where you have PowerShell installed? Could you please try setting the path in the teamcity.powershell.detector.search.paths property (in /conf/buildAgent.properties file) and see if it helps?

If you are going to try Windows containers please see latest comments in the linked issue.

JuliaResh avatar Apr 07 '20 12:04 JuliaResh

@JuliaResh - thank you for the additional information, that was very helpful. After I posted I re-read what the log output said "please provide install locations in teamcity.powershell.detector.search.paths" and was like maybe I should have tried that first! Regardless, your posted help clarify where to add that setting. So, I confirmed that Powershell Core was install on the instance, copied the path and added to the buildAgent.properites file like this:

teamcity.powershell.detector.search.paths=/root/.dotnet/tools

Restarted the instance in Docker and started my TC server instance, and tried out a build and viola... build ran!

For clarity I installed Powershell Core as a global tool on the Agent container like this:

  • dotnet tool install --global PowerShell - which by default installs in /root/.dotnet/tools
  • updated the PATH to include that path so pwsh can be called from anywhere

If the TC Build Agent Ubuntu images will not have Powershell installed on them then perhaps some documentation on how to set it up would be helpful.

Thank you for your help!

stevekumbsky avatar Apr 08 '20 12:04 stevekumbsky

@stevekumbsky Indeed TeamCity currently does not detect PowerShell installed as a global tool (you can watch and vote for TW-61415).

Please note that when installed as a tool PowerShell has issues with arguments parsing (see https://github.com/PowerShell/PowerShell/issues/11747) which may cause problems in your builds.

This article describes how to install PowerShell on linux from the package repository or direct package download.

JuliaResh avatar Apr 09 '20 09:04 JuliaResh

Ok. I'm seeing this now (3 years later). Why the heck would it be wanting powershell on a linux debian host?! Does it not autodetect that it aint running on windows?

shayneoneill avatar Feb 26 '24 02:02 shayneoneill

I assume that I fixed it, but I can't remember how. Also...

⛔ This repository is no longer supported, please consider using teamcity-docker-images instead.

sjauld avatar Feb 26 '24 04:02 sjauld