如果我的代码需要在Windows服务器上运行,如何构建gitlab管道?

问题描述 投票:0回答:2

我实现了一堆需要在Window Server上运行的基础架构检查(PowerShell脚本)(大多数都使用Get-WmiObject cmdlet)。我把它们和他们的Pester测试放在GitLab上并尝试构建一个管道。

我读过creating-your-first-windows-container-with-docker-for-windowsbuilding-a-simple-release-pipeline-in-powershell-using-psake-pester-and-psdeploy,但我很困惑。我的理解是,为了让代码在GitLab CI上运行,我需要构建一个Windows Server docker镜像吗?

以下是我的.gitlab-ci.yml文件,但它有身份验证错误,图像可以找到here

image: ltsc2019

stages:
  - build
  - test
  - deploy

build:
  stage: build
  script:  
  # run PowerShell script
    - powershell -File "\Deploy\Build.ps1"

test:
  stage: test
  script:
    - powershell -File "\Deploy\CodeCoverage.ps1"

deploy:
  stage: deploy
  script:
    - powershell -File "\Deploy\Deploy_Local.ps1"

它不会通过初始构建,这是我得到的错误:

# Error 1
ERROR: Job failed: Error response from daemon: pull access denied for ltsc2019, repository does not exist or may require 'docker login' (executor_docker.go:168:3s)

# Error 2 (this happened because I added 'shell: "powershell"' 
# after executor in the gitlab-runner congif file)
ERROR: Preparation failed: Docker doesn't support shells that require script file
powershell docker gitlab gitlab-ci windows-server
2个回答
0
投票

ltsc2019mcr.microsoft.com/windows/servercore的一个标签。

您需要在.gitlab-ci.yml的开头引用此图像:

image: mcr.microsoft.com/windows/servercore:ltsc2019


0
投票

任何努力在Docker for Windows上使用docker图像的人都请阅读Docker executor currently doesn't support Docker for Windows。如果您正在构建需要容器来运行它的管道,请查看executor

© www.soinside.com 2019 - 2024. All rights reserved.