to push the latest changes to jenkins

7 views
Skip to first unread message

sakshira...@gmail.com

unread,
Aug 11, 2020, 3:38:06 AM8/11/20
to Jenkins Users
Hello all, 

Is there any way that i can remotely push my recent changes related to file transfer or file changes from one server to other using git repository to jenkins.

eg: if my local repository has any file changes i am pushing it to my repository using below set of command in a script:

#!/bin/bash
. inputfile.txt
cp -r $DIR .

git config --global user.email "some email"
git config --global user.name "Some user name"

git add .

commitMessage="commiting the new file"
echo $commitMessage

#read commitMessage

git commit -m "$commitMessage"
git remote set-url origin somerepositoryurl.git
branch=master
echo $branch
#read branch

git push origin master --force

sleep 10
echo "execute piecebypiece now"

./piecebypiece.sh

echo "script execution done"

when i run this script in local it works fine and push the latest changes but when i run the same in jenkins below error is encountererd:

error: src refspec master does not match any. error: failed to push some refs to 'gitrepository.git'
 
if i make changes in  inputfile.txt and run script on jenkins those changes are not visible untill i run script on local.

Could you please advise how can my recent changes can come to jenkins if i directly execute script in jenkins.


Reply all
Reply to author
Forward
0 new messages