Hi, how can I implement this multi-line code as a ‘sh’ command in a declarative pipeline please?
if [ ! -d $LOCALREPO_VC_DIR ]
then
git clone $REPOSRC $LOCALREPO
else
cd $LOCALREPO
git pull $REPOSRC
fi
Hi, how can I implement this multi-line code as a ‘sh’ command in a declarative pipeline please?
if [ ! -d $LOCALREPO_VC_DIR ]
then
git clone $REPOSRC $LOCALREPO
else
cd $LOCALREPO
git pull $REPOSRC
fi
sh commands are strings, Just use standard groovy multiline strings (triple quotes) if you use single quotes ‘’’ then $'s will be passed to shell and you will not be able to pass in groovy variables into your script, if you use triple-double quotes “”", your ${} expressions will be resolved by groovy before shell runs, so you will need to escape the $ signs you want to pass to shell