LoginSignup
0
0

JenkinsのPipelineからPythonを実行したらcommand not found

Posted at

Pythonをパスを指定して実行したらcommand not foundと言われた

JenkinsのPipelineからパスを指定してPythonを実行したら
command not foundと言われた

${HOME}/.pyenv/shims/python ./test.py


/opt/homebrew/Cellar/pyenv/x.x.x/libexec/pyenv-which: line 61: basename: command not found

Pythonのバージョンが違う?

python --version
Python 3.9.13

pyenv which python
${HOME}/.pyenv/versions/3.9.13/bin/python

バージョンは合ってそうな気がします。

試しにpyenv which pythonの方のPythonを使ってみる

${HOME}/.pyenv/versions/3.9.13/bin/python ./test.py

Finished: SUCCESS

こっちだと成功しました。何故。

JenkinsのPATHを通す

パスを指定してそのまま使っても良かったのですが
Pythonのバージョンを更新した時に、全部のjobに手を入れるのは大変面倒くさいので
JenkinsにPATHを通しました。

Jenkinsの管理 > システムの設定 > グローバル プロパティ > 環境変数
スクリーンショット 2024-02-06 16.39.04.png

PATHを通したので最終的にこうしました

python ./test.py

Finished: SUCCESS
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0