如何在 Gitlab Pages 中将 PowerShell 与 Gitlab CI 结合使用? [英] How do I use PowerShell with Gitlab CI in Gitlab Pages?

查看:23
本文介绍了如何在 Gitlab Pages 中将 PowerShell 与 Gitlab CI 结合使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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
  - .uild.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

这篇关于如何在 Gitlab Pages 中将 PowerShell 与 Gitlab CI 结合使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆