[英]flutter: command not found when run shell script in Jenkins
I have created test.sh with the following content: 我创建了具有以下内容的test.sh:
#!/bin/bash
echo "Hello world"
flutter doctor
Everything works fine when I run this script via Terminal: 通过终端运行此脚本时,一切工作正常:
sh test.sh
But my script fails when I run it via Jenkins. 但是,当我通过Jenkins运行脚本时,脚本将失败。 I get the following error: 我收到以下错误:
line 3: flutter: command not found
My .bash_profile is: 我的.bash_profile是:
export PATH="$PATH:~/Development/flutter/bin"
~
means home directory of current user
. ~
表示home directory of current user
。 So for you it would be ie /home/anivaler
but for Jenkins it most likely be something else. 因此,对于您来说,它应该是/home/anivaler
但对于Jenkins而言,它很可能是其他东西。 To make it work for anyone get rid of ~
and put the full, absolute path, ie 为了使它适用于任何人,请摆脱~
并放置完整的绝对路径,即
export PATH=${PATH}:/home/anivaler/Development/flutter/bin
If you are unsure what should be the proper path, just open terminal, cd
to that directory and do pwd
: 如果不确定什么是正确的路径,只需打开终端, cd
到该目录并执行pwd
:
cd ~/Development/flutter/bin
pwd
which will show you full path to that directory. 这将显示该目录的完整路径。 Then you just need to edit said .bashrc
and you should be good. 然后,您只需要编辑说的.bashrc
,就可以了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.