Reputation: 75
We make a deploy to client's folder at client's server using Jenkins via VPN of several git repos. I've set the "Check out to a sub-directory option" and "Sparse checkout".
We need to deploy only some files of one common repository (other files are private). But if the .git folder is inside, it is not hard to view other files.
For git it is possible to place .git file into repo folder and specify in this file the place to .git folder, e.g.:
my-repo-folder$ cat .git
gitdir: /home/user1/another-my-repo-folder.git
(see more here about gitdir)
Is it possible to set another place of .git folder for git Jenkins plugin like above?
Upd. Here is the deploy configuration of the described above:
Upvotes: 1
Views: 1374
Reputation: 75
I've found the workaround: I've created post-checkout script (howto) in local repo, and checkout to a different workspace inside them (howto) and write .git file inside them. As a result Jenkins pull and do sparse checkout by git plugin in local repo, and post-checkout script do the rest.
The post-checkout script:
#!/bin/sh
if [[ "$GIT_POST_CHECKOUT_SCRIPT_CALL" -ne 1 ]]
then
GIT_WORK_TREE=S:/clients-repo-path/ # remote share should be connected as a drive for Windows
GIT_POST_CHECKOUT_SCRIPT_CALL=1 # prevent infinite loop
export GIT_POST_CHECKOUT_SCRIPT_CALL
CUR_DIR=`pwd`
CUR_DIR="${CUR_DIR:1:1}:${CUR_DIR:2}" # translate nix path to git for Windows. Remove for linux
echo "gitdir: $CUR_DIR/.git" > "$GIT_WORK_TREE/.git" # now may run git commands in clients repo
export GIT_WORK_TREE # git option for checkout
git checkout -f # checkout to client's path
fi
Upvotes: 0
Reputation: 51850
Another suggestion :
git
is not a deployment tool (not a good one anyway).
If you need to select some files from your repo, and copy only that to the server, you can :
Upvotes: 1