简体   繁体   中英

Why am I getting fatal: file is outside repository from Jenkins

I am trying to push a file on Git within a Jenkins job:

IN JENKINS I added a Windows shell command job and this is the first command:

git add "C:\Users\AMRABET\Documents\VSC\HW\index.html" 

But I got the following error:

fatal: C:\Users\AMRABET\Documents\VSC\HW\index.html: 'C:\Users\AMRABET\Documents\VSC\HW\index.html' is outside repository

Same command works from Windows CMD. It works well from windows. My question is different because I only get it in Jenkins

Any help?

As suggested in the comments I was just out of the git repo.

Actually when in Jenkins you do

cd C:\Location
AnotherShellAction
git add RandomFile

the git action will be executed not from C:\\Location you mentionned but from the default workspace. It means that you need to enter the wanted Location again after every instruction. Good way would then be:

cd C:\Location
AnotherShellAction
cd C:\Location
git add RandomFile

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM