Add in a test to see if the director exists before doing the copy:

for P in /usr/contrib/bin /usr/local/bin
do
       [ -d $P ] || continue
       cd $P > /dev/null 2>&1
       if [ $? -eq 0 ] 
       then
               // XYZ
               echo $P
       fi
done

This will skip the iteration and go to the top of the for loop if this 
directory doesn't exist. 

--
David Weintraub
da...@weintraub.name

On Aug 14, 2012, at 11:49 AM, natalie_pub...@gmx.net wrote:

> Hi there,
> 
> I'm using Jenkins to build a C++ project on Solaris 10.
> 
> To set up the environment I'm calling various shell scripts, of which one 
> contains the following code:
> --
> for P in /usr/contrib/bin /usr/local/bin
> do
>        cd $P > /dev/null 2>&1
>        if [ $? -eq 0 ] 
>        then
>                // XYZ
>                echo $P
>        fi
> done
> -- 
> 
> The directory "/usr/contrib/bin" does not exist. This makes the return value 
> in line 3 (cd $P > /dev/null 2>&1) negative and Jenkins stops the build 
> because it appears to be "failed".
> 
> In the job configuration, section "Build shell" it already says that the 
> build is considered failed if one of the commands returns <> 0.
> 
> This script has been used for compilation by many other projects for long 
> time, so I don't really want to change it.
> 
> Is there any workaround or solution to this behaviour (except to create this 
> directory)?
> 
> Regards,
> Natalie

Reply via email to