We own a Github organization with hundreds repositories that are authored by contributors. We would like to setup a Jenkins server that performs certain standard tasks for e
Assuming your Jenkins are running in a Linux or MacOS, or in Windows supporting Shell Script commands, configure a Jenkins job to execute the script below. Don't forget to replace the user and password fields and read the comment lines in order to understand and maybe improve it.
curl -i -u "user":"password" "https://github.com/your_organization" | grep "codeRepository" | awk -F '"' '{print $8}' | while read line; do
mkdir "_temp_repo"
cd "_temp_repo"
# `--depth=1` clones the last commit only improving the speed of the clone
# if you want to clone a specific branch add `-b branch` to the command below
git clone --depth=1 "https://github.com"$line .
# execute here your peding commands...
git add .
git commit -am "[pending] XPTO..."
git push
# execute here your success/failure commands...
git add .
git commit -am "[success/failure] XPTO..."
git push
cd ..
rm -rfv "_temp_repo"
done
I would suggest create a SH file and execute in verbose mode: sh -x ./my_script.sh
.
In order to perform it for every new update, setup a Github webhook to this job.