jenkins 无法在Docker中执行powershell命令

t2a7ltrp  于 2022-12-17  发布在  Jenkins
关注(0)|答案(1)|浏览(239)

我正在尝试通过Jenkins使用Docker文件在Docker中执行PowerShell脚本。以前,使用相同的Docker文件可以正常工作,但现在失败了。有人能帮助我吗

FROM mcr.microsoft.com/powershell
WORKDIR /app
COPY htmlReport.ps1 /app
COPY report.json /app
RUN ["pwsh", "htmlReport.ps1"]

下面是jenkins给出的错误

Step 1/5 : FROM mcr.microsoft.com/powershell
latest: Pulling from powershell
e96e057aae67: Pulling fs layer
06c4b2188acf: Pulling fs layer
e96e057aae67: Verifying Checksum
e96e057aae67: Download complete
06c4b2188acf: Verifying Checksum
06c4b2188acf: Download complete
e96e057aae67: Pull complete
06c4b2188acf: Pull complete
Digest: sha256:fe812277f0695af7846ad0cbf9a010e157ffa89ac78c9435b72ff0f1adb8435c
Status: Downloaded newer image for mcr.microsoft.com/powershell:latest
 ---> 925e63c2bfe6
Step 2/5 : WORKDIR /app
 ---> Running in 8618b46d44dd
Removing intermediate container 8618b46d44dd
 ---> 449979b5c145
Step 3/5 : COPY htmlReport.ps1 /app
 ---> 2f3b5600eedc
Step 4/5 : COPY report.json /app
 ---> bf784e946fc2
Step 5/5 : RUN ["pwsh", "htmlReport.ps1"]
 ---> Running in 22e7ae2434ba
Failed to create CoreCLR, HRESULT: 0x80070008
The command 'pwsh htmlReport.ps1' returned a non-zero code: 137
Build step 'Execute shell' marked build as failure
3z6pesqy

3z6pesqy1#

我找到了一个解决方案。Docker文件应该如下所示

FROM mcr.microsoft.com/powershell:7.1.3-ubuntu-20.04
WORKDIR /app
COPY htmlReport.ps1 /app
COPY report.json /app
#RUN ["pwsh", "htmlReport.ps1"]
RUN pwsh -File './htmlReport.ps1'

相关问题