簡體   English   中英

使用gitlab runner時Python不被識別為命令

[英]Python not recognised as command when using gitlab runner

我正在嘗試在gitlab存儲庫上建立持續集成。

我添加了以下gitlab-ci.yml文件:

stages:
 - test


test:
 image: python:3.7
 script:
  - python -v
 tags:
  - python

在gitlab上,在settings-> CI / CD中,我按照'手動設置特定的Runner'中的說明進行操作。 在步驟'請輸入執行者:',我輸入'shell'。

當我嘗試提交上面的yml文件時,運行器開始運行,但它會給出以下錯誤消息:

Running with gitlab-runner 11.9.2 (fa86510e)
  on wsf-1102 HUx_zvP8
Using Shell executor...
Running on WSF-1102...
DEPRECATION: this GitLab server doesn't support refspecs, gitlab-runner 12.0 will no longer work with this version of GitLab
Fetching changes...
Clean repository
From [my_repo]
   e327c9f..2f0e41f  [my_branch]-> origin/[my_branch]
Checking out 2f0e41f1 as [my_branch]...

Skipping Git submodules setup
$ python -v
'python' is not recognized as an internal or external command,
operable program or batch file.
ERROR: Job failed: exit status 9009

我應該如何正確編寫yml文件,以便我可以使用python作為命令以便以后運行test.py文件?

問題不在於跑步者在你的碼頭圖片中。 在運行器上下文中,您沒有安裝python來確認第一次測試python已正確安裝在終端路徑中。 然后,在使用和docker鏡像之前,先使用shell執行器進行調試

嘗試運行此命令

gitlab-runner exec shell test

在這個簡單的.gitlab-ci.yml上 (把文件放在你的git repo文件夾里

stages:
 - test


test:
 script:
  - python -v

然后嘗試使用python圖像當你想要使用這個圖像時,你需要指定你想要在你的本地機器上測試上述情況后運行docker runner

gitlab-runner exec docker test

如果您仍然想要了解它,請嘗試遵循本指南https://substrakt.com/journal/how-to-debug-gitlab-ci-builds-locally/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM