[英]Unable to change directory in Shell Script running on Jenkins
I am trying to run a shell script on Jenkins and want to change the directory. 我正在尝试在Jenkins上运行Shell脚本,并想更改目录。 My code is as follows :
我的代码如下:
#!/bin/bash
pwd
function myprog() {
cd root/data
}
myprog
pwd
I tried all possibilities mentioned in the question posted here . 我尝试了此处发布的问题中提到的所有可能性。
I tried symbolic links, Alias and function, however no success. 我尝试了符号链接,别名和功能,但是没有成功。 In the jenkins console output i always get the following error :
在jenkins控制台输出中,我总是收到以下错误:
/tmp/hudson772738020072372550.sh: line 11: cd: root/data: No such file or directory
What i notice here is that, there is a colon after cd, is that creating some issue? 我在这里注意到的是,在cd后面有一个冒号,这是否会引起一些问题? Kindly help.
请帮助。 Thanks.
谢谢。
This is the shell's way of saying that the string root/data
does not correspond with any directory below the current directory. 这是Shell的一种说法,即字符串
root/data
与当前目录下的任何目录都不对应。
You probably meant to say cd /root/data
instead. 您可能想说
cd /root/data
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.