0

I am running a shell build step in Jenkins (Windows), but, it doesn't seem to recognize the rev command. The command I am trying to run is:

awk '/Connections/||/Endpoint/||/connections/||/endpoint/||/EndPointURI/ {print $config}' "$config" | rev | cut -c 8- | rev  >temp11

I have used sed '/\n!G;s/\(.\)\(.*\n\)/&\2\1/;//D;s/.//' to replace each instance of rev.

I have the following:

awk '/Connections/||/Endpoint/||/connections/||/endpoint/||/EndPointURI/ {print $config}' "$config" | sed '/\n!G;s/\(.\)\(.*\n\)/&\2\1/;//D;s/.//' | cut -c 8- | sed '/\n!G;s/\(.\)\(.*\n\)/&\2\1/;//D;s/.//'  >temp11

Using this method, I get the following error in the Jenkins output:

+ awk '/Connections/||/Endpoint/||/connections/||/endpoint/||/EndPointURI/ {print $config}' 'C:\Program Files (x86)\Jenkins/workspace/DeploymentFiles/BUILD.xml'
+ sed '/\n!G;s/\(.\)\(.*\n\)/&\2\1/;//D;s/.//'
+ cut -c 8-
sed: -e expression #1, char 9: unknown command: `\'
+ sed '/\n!G;s/\(.\)\(.*\n\)/&\2\1/;//D;s/.//'
sed: -e expression #1, char 9: unknown command: `\'
Build step 'Execute shell' marked build as failure
Finished: FAILURE

Not sure how to fix this or make it work.


Full script:

touch "${JENKINS_HOME}"/workspace/DeploymentFiles/UAT.properties
config=${JENKINS_HOME}/workspace/DeploymentFiles/BUILD.xml
properties=${JENKINS_HOME}/workspace/DeploymentFiles/UAT.properties
a='tibco.clientVar.'
awk '/Connections/||/Endpoint/||/connections/||/endpoint/||/EndPointURI/ {print $config}' "$config" | sed '/\n!G;s/\(.\)\(.*\n\)/&\2\1/;//D;s/.//' | cut -c 8- | sed '/\n!G;s/\(.\)\(.*\n\)/&\2\1/;//D;s/.//'  >temp11
awk '/Connections/||/Endpoint/||/connections/||/endpoint/||/EndPointURI/ {getline; print $config}' "$config" |sed '/\n!G;s/\(.\)\(.*\n\)/&\2\1/;//D;s/.//' | cut -c 9- | sed '/\n!G;s/\(.\)\(.*\n\)/&\2\1/;//D;s/.//'  >temp22
sed -e s/'<name>'//g -i temp11
sed -i '/^$/d' temp11
sed -e s/'<value>'//g -i temp22
sed -i '/^$/d' temp22
while read -r line
do
echo "${a}$line"
done <temp11 >temp3
sed -i '/^$/d' temp3
paste -d'=' temp3 temp22 >  final
sed '/^tibco.clientVar.<checkpoint>/d' final > final.new && mv final.new final
mv final ${properties}
Idris.AH
  • 410
  • 1
  • 10
  • 22
  • 1
    If you could do let us know samples of input and expected output in CODE TAGS in your post, we could help you more on this, please do add the same in your post. – RavinderSingh13 Mar 26 '18 at 11:50
  • you are using `{print $config}`, so awk will try to print the field in the `config`-th position (eg, like saying `seq 10 | awk '{print $bla}'`, which prints everything). But you are not setting `config` anywhere. Are you maybe trying to use the shell variable `$config`? – fedorqui Mar 26 '18 at 12:00
  • I have set the config variable before that. I will update the question. – Idris.AH Mar 26 '18 at 12:07
  • Check [How do I use shell variables in an awk script?](https://stackoverflow.com/q/19075671/1983854) – fedorqui Mar 26 '18 at 13:21

0 Answers0