Jhack February 2016

Chef - Clone a specific tag from GitLab

I have this snippet where I should clone a repo from git:

git "somerepo" do
  action :sync
  destination "/var/"
  repository "http://#{node["somerepo"][:git_user]}:#{node["somerepo"][:git_pass]}@#{node["somerepo"][:git_host]}/#{node["somerepo"][:git_owner]}/somerepo.git"
  revision "#{node["somerepo"][:git_revision]}"
  user "root"
  group "root"

I have these several tags in a GitLab repo named like: 12022015 01052016 02042016

I want tags/02042016 to be cloned/checked out just how I set the settings in SVN. Please help. I kinda searched StackOverflow and I wish I am just overlooking a previous question like this. And if this is not possible, kindly advise so. :) Thank you.


StephenKing February 2016

As the documentation suggests, you can supply tag names to the revision parameter.

git "apt-cookbook" do
  repository "https://github.com/chef-cookbooks/apt"
  revision "v2.9.2"
  action :sync

As this usage of the revision parameter is not bullet-proof (not sure, what happens, when a branch with the same name exists), you can also submit the complete Git refspec for the tag, which is refs/tags/<tagname>:

git "apt-cookbook" do
  repository "https://github.com/chef-cookbooks/apt"
  revision "refs/tags/v2.9.2"
  action :sync

Post Status

Asked in February 2016
Viewed 3,589 times
Voted 6
Answered 1 times


Leave an answer