如何在Gitlab页面中将PowerShell与Gitlab CI一起使用?
如何在.gitlab-ci.yml
文件中将PowerShell命令/脚本与Gitlab CI一起使用,该文件用于部署到gitlab页面?
How do I use PowerShell commands/scripts with Gitlab CI in a .gitlab-ci.yml
file which is used to deploy to gitlab pages?
我正在尝试从.gitlab-ci.yml
执行build.ps1
文件,但是当它到达build.ps1
行时,出现错误提示
/bin/bash:第5行:.build.ps1:找不到命令
I am trying to execute the build.ps1
file from .gitlab-ci.yml
, but when it reaches the build.ps1
line, it gives an error saying
/bin/bash: line 5: .build.ps1: command not found
我正在尝试使用PowerShell脚本转换我的存储库中的文件,并使用.gitlab-ci.yml
I am trying to use the PowerShell script to convert a file in my repo and have the converted file deployed to gitlab pages using .gitlab-ci.yml
这是我的代码:
.gitlab.yml
pages:
stage: deploy
script:
- mkdir .public
- .\build.ps1
- cp -r * .public
- mv .public public
artifacts:
paths:
- public
only:
- master
我已经能够解决自己的问题.
I have been able to figure out a solution to my own question.
解决方案
要使用Gitlab CI从 gitlab.com 上的.gitlab-ci.yml
文件运行PowerShell命令/脚本,您需要确保.gitlab-ci.yml文件的内容是如下所示.
To Run PowerShell Command/Script from a .gitlab-ci.yml
file on a gitlab.com 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 网站.
Note: The .gitlab-ci.yml
below works without having to install a Gitlab Runner on your own machine and has been tested on the http://gitlab.com website.
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