LoginSignup
2
2

More than 5 years have passed since last update.

ItamaeでBitbucketのprivate repositoryからcloneする方法

Last updated at Posted at 2016-07-07

普通にgitリソースでやると,色々な事情で出来ませんでした.詳しくは私の2016年7月7日のTwitterのログを見て下さい.

用意するレシピはおおよそ以下のようになります.

git cloneするシェルスクリプトファイルを用意してやってそれをexecuteで実行します.

id_rsa (秘密鍵) は予めローカルのどこか (/some/where) に用意しておきます.

username = 'ka'

directory "/home/#{username}/.ssh" do
  owner username
  mode '755'
end

remote_file "/home/#{username}/.ssh/id_rsa" do
  source '/some/where/id_rsa'
  owner username
  mode '400'
end

execute 'SSH config' do
  command <<-EOH
cat <<EOS >> /home/#{username}/.ssh/config
host bitbucket.org
  StrictHostKeyChecking no
EOS
EOH
  not_if "grep -q bitbucket.org /home/#{username}/.ssh/config"
end

file "/home/#{username}/git-clone.sh" do
  content "git clone git@bitbucket.org:username/reposname.git /tmp/repos"
  user username
  mode '644'
end

execute 'git clone' do
  command "bash /home/#{username}/git-clone.sh"
  user username
  not_if 'test -d /tmp/repos'
end

本当は,こんなことしなくてもいいのであれば嬉しいです.

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2