Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Powershell environment variables not set correctly? #31

Open
vyruz1986 opened this issue Jan 28, 2019 · 16 comments
Open

Powershell environment variables not set correctly? #31

vyruz1986 opened this issue Jan 28, 2019 · 16 comments

Comments

@vyruz1986
Copy link

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...?

@domingoladron
Copy link

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

@JuliaResh
Copy link

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.

@thomaswdean
Copy link

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

@domingoladron
Copy link

domingoladron commented Jul 25, 2019 via email

@hulvei3
Copy link

hulvei3 commented Feb 17, 2020

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?

@sjauld
Copy link

sjauld commented Mar 31, 2020

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.

@JuliaResh
Copy link

@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?

@stevekumbsky
Copy link

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

@ricohomewood
Copy link

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

@JuliaResh
Copy link

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

@stevekumbsky
Copy link

@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.

@JuliaResh
Copy link

@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.

@stevekumbsky
Copy link

@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!

@JuliaResh
Copy link

JuliaResh commented Apr 9, 2020

@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 PowerShell/PowerShell#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.

@shayneoneill
Copy link

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?

@sjauld
Copy link

sjauld commented Feb 26, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants