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

前端 未结 3 1305
遇见更好的自我
遇见更好的自我 2021-02-14 18:12

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 b

相关标签:
3条回答
  • 2021-02-14 18:50

    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
    
    0 讨论(0)
  • 2021-02-14 18:50

    For anyone who is having trouble launching grunt within their gitlab CI/CD via a powershell file, add this line to the top of your file:

    $env:path += ";" + (Get-Item "Env:AppData").Value + "\npm"
    
    0 讨论(0)
  • 2021-02-14 19:03

    The docker image philippheuer/docker-gitlab-powershell is outdated. The source on Github was also deleted.

    I use in my gitlab-ci.yml the following image mcr.microsoft.com/powershell:latest more Informations available here

    scriptjob:
      stage: script
      image: 
        name: "mcr.microsoft.com/powershell:latest"
      script:
        - pwsh ./myscript.ps1
    
    0 讨论(0)
提交回复
热议问题