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

[ci.jenkins.io] Provides both powershell and pwsh on all agent templates #2974

Closed
dduportal opened this issue Jun 7, 2022 · 11 comments
Closed

Comments

@dduportal
Copy link
Contributor

Service(s)

ci.jenkins.io

Summary

As per jenkinsci/workflow-basic-steps-plugin#203, it seems that powershell cannot be used on the Jenkins inbound images with nanoserver.

java.io.IOException: Cannot run program "powershell" (in directory "…"): CreateProcess error=2, The system cannot find the file specified
$ docker run --rm -ti --entrypoint=powershell jenkins/jnlp-agent-maven:windows-nanoserver
docker: Error response from daemon: container dd73e4c79e13c68fb1d113ddf0bb3ce966102591fb4d9fe0acd54e940caf83c7 encountered an error during hcsshim::System::CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2)
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: onecore\vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(173)\vmcomputeagent.exe!00007FF7FC739F4B: (caller: 00007FF7FC6EE13A) Exception(6) tid(39c) 80070002 The system cannot find the file specified.
    CallContext:[\Bridge_ProcessMessage\VmHostedContainer_ExecuteProcess]
 Provider: 00000000-0000-0000-0000-000000000000].

https://docs.microsoft.com/en-us/windows-server/get-started/powershell-on-nano-server#differences-in-powershell-on-nano-server powershell (core) should be available by default?

it seems that there is an issue on the upstream image jenkins/jnlp-agent-maven:windows-nanoserver .

Work is going on checking the base image of jenkins/jnlp-agent-maven:windows-nanoserver and check the status before trying to find a solution: Jesse was ablme to use "bat" instead of "powershell" for the tests so no blocker.

Reproduction steps

No response

@dduportal dduportal added this to the infra-team-sync-2022-06-14 milestone Jun 7, 2022
@github-actions github-actions bot added ci.jenkins.io triage Incoming issues that need review labels Jun 7, 2022
@dduportal dduportal removed the triage Incoming issues that need review label Jun 7, 2022
@dduportal
Copy link
Contributor Author

So, the "absence" of powershell CLI comes from the base image which is used:

docker run --rm -ti --entrypoint=powershell jenkins/inbound-agent:4.13-2-jdk11-nanoserver-1809
docker: Error response from daemon: container 24926b5ebd54922df0fabb9dd5853b0882e00b67a924c2d1f7139b2092eec75b encountered an error during hcsshim::System::CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2)
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: onecore\vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(173)\vmcomputeagent.exe!00007FF7FC739F4B: (caller: 00007FF7FC6EE13A) Exception(6) tid(3a0) 80070002 The system cannot find the file specified.
    CallContext:[\Bridge_ProcessMessage\VmHostedContainer_ExecuteProcess] 
 Provider: 00000000-0000-0000-0000-000000000000].

(https://github.com/jenkinsci/docker-inbound-agent/blob/master/11/windows/nanoserver-1809/Dockerfile#L25 -> https://github.com/jenkinsci/docker-agent/blob/master/11/windows/nanoserver-1809/Dockerfile#L30)

@lemeurherve
Copy link
Member

docker run --rm -ti --entrypoint=powershell mcr.microsoft.com/powershell:nanoserver-1809
docker: Error response from daemon: container 2dde7b4e7fc5f0e6ac4a356971c71debe5c5aeab054d2a62497f57bc2a6ddf43 encountered an error during hcsshim::System::CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2).

Same for the base Microsoft nanoserver image (?)

@lemeurherve
Copy link
Member

Oh...
It's pwsh and not powershell: https://github.com/PowerShell/PowerShell-Docker/blob/master/release/7-2/nanoserver1809/docker/Dockerfile#L90

docker run --rm -ti --entrypoint=pwsh mcr.microsoft.com/powershell:nanoserver-1809
PowerShell 7.2.4
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

@dduportal
Copy link
Contributor Author

I think we are missing something with the pwsh.exe command line, that seems to be the default entrypoint (https://github.com/PowerShell/PowerShell-Docker/blob/master/release/7-2/nanoserver1809/docker/Dockerfile#L90).

@dduportal
Copy link
Contributor Author

OK, I'm 200% confused by the pipeline steps:

Ping @jnord if you have any pointer to explain the difference for mere mortals such as us 😅

@jtnord
Copy link

jtnord commented Jun 7, 2022

right.
powershell core is a cut down version and is more cross platform (this is what you get with the linux distros) binary is pwsh.exe vs powershell.exe..
hence the 2 steps - we just forgot and used the wrong one...

@dduportal
Copy link
Contributor Author

right. powershell core is a cut down version and is more cross platform (this is what you get with the linux distros) binary is pwsh.exe vs powershell.exe.. hence the 2 steps - we just forgot and used the wrong one...

Oh I see. I assume that jenkins is not able to "guess" based on what it discovers on its PATH, is that correct?

Would the proposal of @lemeurherve make sense (e.g. adding a powershell alias) to avoid end user to step in the same trap?

@lemeurherve
Copy link
Member

I think I'll make sure pwsh.exe is available on all our agents, then update the shared pipeline to use pwsh instead of powershell

@lemeurherve
Copy link
Member

I'll also intend to install Windows Powershell 5.1 (powershell.exe) alongside Powershell 7 (pwsh.exe) so either command could be used.

IMO favoring pwsh instad of powershell in pipelines should be emphasized in doc somehow (maybe on the pipeline syntax reference page?), at least a note about their differences.
(last one I've noticed, the operator || isn't recognized with powershell)

@jglick
Copy link

jglick commented Jun 21, 2022

should be emphasized in doc somehow

Feel free to file a documentation PR to workflow-durable-task-step-plugin.

lemeurherve pushed a commit to lemeurherve/workflow-durable-task-step-plugin that referenced this issue Jun 24, 2022
dduportal added a commit to jenkins-infra/packer-images that referenced this issue Jun 24, 2022
…available (#260)

* chore: sort tools-versions.yaml

* fix: ensure both Windows Powershell and Powershell Core are available

Ref: jenkins-infra/helpdesk#2974

* fix equals

* Update provisioning/windows-provision.ps1

* add paths

* Update provisioning/windows-provision.ps1

* remove unused versions

* hotfix(Jenkinsfile) increase build timeout as temporary measure

Co-authored-by: Damien Duportal <damien.duportal@gmail.com>
car-roll pushed a commit to jenkinsci/workflow-durable-task-step-plugin that referenced this issue Jun 27, 2022
@dduportal dduportal changed the title [ci.jenkins.io] Provides powershell on the Windows Docker images used on ACI [ci.jenkins.io] Provides powershell on the Windows Docker images used on ACI (Azure Container Instances) Jun 28, 2022
@dduportal dduportal changed the title [ci.jenkins.io] Provides powershell on the Windows Docker images used on ACI (Azure Container Instances) [ci.jenkins.io] Provides both powershell and pwsh on all agent templates Jun 28, 2022
@lemeurherve lemeurherve removed this from the infra-team-sync-2022-06-28 milestone Jun 28, 2022
@lemeurherve
Copy link
Member

After spending too much time trying to install Windows PowerShell in our nanoserver images, and PowerShell Core in our windowsserver images, I'm closing this issue since:

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

No branches or pull requests

5 participants