导入模块找不到容器安装的模块

时间:2020-04-01 10:14:21

标签: linux docker jenkins powershell-core

在Jenkins中,当我运行管道并尝试使用容器中的模块时,我得到的模块如下所示:

我正在使用“ Powershell”构建步骤。

当我以交互方式运行容器时,我可以看到如下模块(#3):

1

<div class="image-box">
  <div class="fuss-img">
    <a href="#">
      <img src="https://i.ibb.co/xGz75Q3/pim-chu-294493-unsplash.jpg">
      <span class="fuss-icon">
        <object>
          <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="50pt" height="50pt" viewBox="0 0 50 50">
            <g id="surface24150293">
              <path style=" stroke:none;fill-rule:nonzero;fill:rgb(100%,100%,100%);fill-opacity:1;" d="M 25 2 C 12.308594 2 2 12.308594 2 25 C 2 37.691406 12.308594 48 25 48 C 37.691406 48 48 37.691406 48 25 C 48 12.308594 37.691406 2 25 2 Z M 25 4 C 36.609375 4 46 13.390625 46 25 C 46 36.609375 36.609375 46 25 46 C 13.390625 46 4 36.609375 4 25 C 4 13.390625 13.390625 4 25 4 Z M 18 13.25 L 18 36.75 L 19.5 35.875 L 36.5 25.875 L 37.96875 25 L 36.5 24.125 L 19.5 14.125 Z M 20 16.75 L 34 25 L 20 33.25 Z M 20 16.75 "></path>
            </g>
          </svg></object>
      </span>
    </a>
  </div>
</div>

这是我的 dockerfile

2

[Tatux.Utils] $ pwsh -NonInteractive -NoProfile -File /tmp/jenkins1449086927549124636.ps1
################################
Running on node 745612521e5a
Build: jenkins-Powershell-Tatux.Utils-16
################################


    Directory: /opt/microsoft/powershell/7/Modules

ModuleType Version    PreRelease Name                                PSEdition
---------- -------    ---------- ----                                ---------
Manifest   1.2.5                 Microsoft.PowerShell.Archive        Desk     
Manifest   7.0.0.0               Microsoft.PowerShell.Host           Core     
Manifest   7.0.0.0               Microsoft.PowerShell.Management     Core     
Manifest   7.0.0.0               Microsoft.PowerShell.Security       Core     
Manifest   7.0.0.0               Microsoft.PowerShell.Utility        Core     
Script     1.4.6                 PackageManagement                   Desk     
Script     2.2.3                 PowerShellGet                       Desk     
Script     2.0.5                 PSDesiredStateConfiguration         Core     
Script     2.0.0                 PSReadLine                          Desk     
Binary     2.0.3                 ThreadJob                           Desk     
[91mImport-Module: [0m/tmp/jenkins1449086927549124636.ps1:9
[96mLine |
[96m   9 | [0m [96mImport-Module Pester, PSScriptAnalyzer[0m
[96m     | [91m ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[91m[96m     | [91mThe specified module 'Pester' was not loaded because no valid module file was found in any module directory.
[0m
Build step 'PowerShell' marked build as failure
Recording NUnit tests results
FATAL: No NUnit test report files were found. Configuration error?
Finished: FAILURE 

交互式tty会话的输出:

3

Interactive tty session with container using image

1 个答案:

答案 0 :(得分:0)

您可以在致电Import-Module之前尝试以下方法:

Get-Module -ListAvailable -Refresh | Out-Null 


另外,您也可以使用其绝对路径导入Pester:

Import-Module /root/.local/share/powershell/Modules/Pester
相关问题