Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use PowerShell with Gitlab CI in Gitlab Pages?

How do I use PowerShell commands/scripts with Gitlab CI in a .gitlab-ci.yml file which is used to deploy to gitlab pages?

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

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

Here is my code:

.gitlab.yml

pages:
  stage: deploy
  script:
  - mkdir .public
  - .\build.ps1
  - cp -r * .public
  - mv .public public
  artifacts:
    paths:
    - public
  only:
  - master
like image 885
Ishan Avatar asked Jun 02 '17 01:06

Ishan


1 Answers

I have been able to figure out a solution to my own question.

Solution

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.

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
like image 98
Ishan Avatar answered Sep 27 '22 21:09

Ishan