シーン
あなたは地元企業のネットワークやサーバーのgitlab内の仮想マシンを展開する場合、ネットワーク制御と管理は、プロジェクトベースのバージョン管理運営を展開することができ、その制御を達成するか、同時にネットワークのローカライズされたバージョンを管理する方法、内部のローカライズバージョンを願っていますかオンラインサーバー、これについては後述する問題があります。
上記のプログラムは、チェックポイントが存在します
-
リモートサーバーのクローンを作成するか、ローカルコードgitlabを同期する方法
-
同期リモートサーバーを自動化するプロジェクトを展開する方法gitlab
実装プロセス
倉庫を構築
-
gitlabでプロジェクトを確立する(すなわち、gitlabで倉庫を確立するプロセス)
-
リモートサーバにおける裸倉庫の確立
-
gitlabローカル倉庫のクローニング
展開のssh-キー
- 生成
ssh-keygen -t rsa -C "[email protected]"
-
gitlabでローカルのsshキーを展開します
最初のステップ:
ステップ2:
- SSHキーのリモートサーバーのGitlabの展開
展開のフック
- 設定ファイルの.sshファイルgitlabの構成情報
host test
hostname 0.0.0.0 #你的主机地址
user root
port 22
identityfile ~/.keys/test #你的私钥地址
- gitlab custom_hooks倉庫の下にフォルダを作成し、custom_hookにポスト受信を作成、編集
#!/bin/sh
# example hook script for the "post-receive" event.
#
# The "post-receive" script is run after receive-pack has accepted a pack
# and the repository has been updated. It is passed arguments in through
# stdin in the form
# <oldrev> <newrev> <refname>
# For example:
# aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master
#
# see contrib/hooks/ for a sample, or uncomment the next line and
# rename the file to "post-receive".
#. /usr/share/git-core/contrib/hooks/post-receive-email
while read oldrev newrev ref
do
branch=$(git rev-parse --symbolic --abbrev-ref $ref)
if [ "$branch" = "1.0" ]
then
git push -f test:/var/www/html/test.git $branch
fi
done
- リモート裸のリポジトリに配備フック
#!/bin/sh
#
# An example hook script for the "post-receive" event.
#
# The "post-receive" script is run after receive-pack has accepted a pack
# and the repository has been updated. It is passed arguments in through
# stdin in the form
# <oldrev> <newrev> <refname>
# For example:
# aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master
#
# see contrib/hooks/ for a sample, or uncomment the next line and
# rename the file to "post-receive".
#. /usr/share/git-core/contrib/hooks/post-receive-email
while read oldrev newrev ref
do
if [[ $ref =~ .*/1.0$ ]];
then
echo "1.0 ref received. Deploying 1.0 branch to test server..."
git --work-tree=/var/www/html/test--git-dir=$GIT_DIR checkout -f $ref
fi
done
テスト
- 新しいローカルファイルには、提出され、サービスをテストする方法を自動的に更新することができ、その展開を成功