如何在Gitlab页面中将PowerShell与Gitlab CI一起使用?

Ish*_*han 6 powershell continuous-integration gitlab gitlab-ci gitlab-pages

如何在.gitlab-ci.yml用于部署到gitlab页面的文件中将PowerShell命令/脚本与Gitlab CI一起使用?

我正在尝试从执行build.ps1文件.gitlab-ci.yml,但是当它到达该build.ps1行时,它给出了一个错误,提示 / bin / bash:第5行:.build.ps1:找不到命令

我正在尝试使用PowerShell脚本转换我的仓库中的文件,并使用以下命令将转换后的文件部署到gitlab页面 .gitlab-ci.yml

这是我的代码:

.gitlab.yml

pages:
  stage: deploy
  script:
  - mkdir .public
  - .\build.ps1
  - cp -r * .public
  - mv .public public
  artifacts:
    paths:
    - public
  only:
  - master
Run Code Online (Sandbox Code Playgroud)

Ish*_*han 7

我已经能够找到解决我自己问题的方法。

gitlab.com.gitlab-ci.yml上的文件运行PowerShell命令/脚本 using the Gitlab CI, you need to make sure that the contents of your .gitlab-ci.yml file is as shown below.

注意:.gitlab-ci.yml下面的方法无需在您自己的计算机上安装Gitlab Runner,并且已经在http://gitlab.com网站上进行了测试。

image: philippheuer/docker-gitlab-powershell

pages:
  stage: deploy
  script:
  - mkdir .public
  # run PowerShell Script
  - powershell -File build.ps1
  # run PowerShell Command
  - powershell -Command "Get-Date"
  - cp -r * .public
  - mv .public public
  artifacts:
    paths:
    - public
  only:
  - master
Run Code Online (Sandbox Code Playgroud)


liv*_*ve2 6

docker 镜像philippheuer/docker-gitlab-powershell已过时。Github上的源码也被删除了。

gitlab-ci.yml在下图中使用了此处mcr.microsoft.com/powershell:latest提供的更多信息

scriptjob:
  stage: script
  image: 
    name: "mcr.microsoft.com/powershell:latest"
  script:
    - pwsh ./myscript.ps1
Run Code Online (Sandbox Code Playgroud)