简体   繁体   中英

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. 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 :

/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? 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.

You probably meant to say cd /root/data instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM