GitLab CI用于Python的共享Windows runner

2024-04-29 05:15:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我在GitLab中有一个python项目repo。我看到GitLab在测试版中共享了Windows runner(请参阅this文章)

我想知道在Windows shared runner上是否有python的标准gitlab-ci.yml?如果是这样的话,因为这仍然是测试版,我很好奇这有多稳定?对于那些使用过AppVeyor并拥有AppVeyor经验的人来说,我使用AppVeyor还是使用这个更好

谢谢


Tags: 项目ci标准windowsyml文章gitlab请参阅
2条回答

您可以使用以下代码段:

my_win_job:
  before_script:
    # https://gitlab.com/gitlab-org/ci-cd/shared-runners/images/gcp/windows-containers/-/issues/13
    - Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
    - choco install python3  version=$PYTHON_VERSION  yes  force  no-progress
    - refreshenv
  script:
    - python -V
    - python -m pip install -U pip wheel
  variables:
    PYTHON_VERSION: "3.9"
  tags:
    - windows

我希望它仍然相关,但您可以使用Chocolate在gitlab windows runners创建的虚拟机上安装python,如下一个.gitlab-ci.yml示例:

.shared_windows_runners:
   tags:
     - shared-windows
     - windows
     - windows-1809

before_script:
  - Set-Variable -Name "time" -Value (date -Format "%H:%m")
  - echo ${time}
  - echo "started by ${GITLAB_USER_NAME}"
  - choco install python  version=3.7.0 -y -f

stages:
  - build

build_somthing:
  extends:
    - .shared_windows_runners
  stage: build
  script:
    - "C:\\Python37\\python.exe -m pip install  upgrade setuptools"
    - "C:\\Python37\\python.exe -m pip install -r requirements.txt"

Chocolate将在路径C:\Python37中安装python,因此如果您想使用python,可以按如下方式使用它:“C:\Python37\python.exe-m pip安装升级设置工具”

相关问题 更多 >