Issue
i am currently planning to register and utilize the git repository in redmine.
Because redmine is not managed through remote url, there was a problem that you had to git clone it and leave the fetch periodically.
It could have been handled simply through the git credential store
, but I decided there was a security problem, so I encrypted the netrc file with the netrc.gpg file and then made the git-credential-netrc file fetch through git.credential = netrc -v
.
These tasks were written after seeing the reference materials below.
In particular, I referred to the reference number 1, and I also checked that the shell script works normally when it is turned locally after making the shell script as below.
- update-git-repo.sh
#!/bin/bash
cd ${PROJECT_DIR}
for entry in `ls -d */`
do
echo "$entry"
cd ${entry} && {
git remote update
cd ..
}
done
- correct result
However, there was a problem when turning this shell script file into crontab to operate it periodically.
- crontab -e
# m h dom mon dow command
*/1 * * * * /home/vanilla/redmine/docker-redmine/update-git-repo.sh >> ~/cron.log 2>&1
- cron.log
At first, I thought it would be a user permission issue, but the shell script worked fine when it was operated by a user named vanilla
, and I checked the crontab file of the user with crontab -e -u vanilla
and confirmed that it was in the file.
What's the problem?
I am attaching a link to the file in the git-credential-netrc I used, although I don't know if it can help.
Solution
It was a very simple problem. I changed the git global credential option as below and it was solved.
git config --global credential.helper /usr/local/bin/git-credential-netrc
In running local shell script, it works as a git config --global credential.helper "netrc -v"
command, but in the case of crontab, the location of the actual command must be specified and registered as credential due to environmental variables or other problems.
https://gist.github.com/soardex/bd588f633d03d8bd0f84
Answered By - Sean Sin Answer Checked By - Candace Johnson (WPSolving Volunteer)