Tuesday, August 29, 2023

Clone Git Repository on Jenkins and execute a script

 GIT and Jenkins


Create a new job and select Freestyle project. Go directly to Build section and select "Execute Shell"

The jenkin job runs as SYSTEM user, so ensure you have access to folder where you clone the files.

In my case, I have a SYSTEM user on the system with $HOME directory /home/system. Will close git repo into scripts folder

added following entries in the command section

cd /home/system

rm -rf scripts

git clone https://github.com/yashwanthsn2020/automation.git scripts
./scripts/api_showpassword.sh


./scripts/listfiles.sh


./scripts/crontab.sh

 Click on Save

Click on Build Now, check the console output