I am facing some challenges to write my bash script code inside the Jenkinsfile.
UserCase: I am keeping multiple tools code in the folder structure in one GIT repo. I want whenever any developer makes the change to the individual folder, a build gets triggered for specific folder related code.
My Logic: Pick the last two commit, find the difference. On the basis of difference, make the build as per changed files.
I wrote the bash script and it works fine on linux machine. After moving it inside the Jenkinsfile, i am facing some error.
This might be groovy specific.
Need Help in these
#!/bin/bash
git log -2 --no-merges | grep commit > git_commit.txt
cat git_commit.txt
echo 'hi'
i=0;
while read -r line;
do
commit[$i]=`echo "$line" | awk '{print \$2}'`
i=$((i+1))
done < git_commit.txt
This is not the complete code. I am getting error in assigning value:
commit[$i]=`echo "$line" | awk '{print \$2}'`
Let me know if you know further explanation to help.