{"id":548,"date":"2009-10-09T11:57:12","date_gmt":"2009-10-09T17:57:12","guid":{"rendered":"http:\/\/www.mooreds.com\/wordpress\/archives\/000548"},"modified":"2009-10-09T11:57:12","modified_gmt":"2009-10-09T17:57:12","slug":"setting-variables-across-tasks-in-capistrano","status":"publish","type":"post","link":"https:\/\/www.mooreds.com\/wordpress\/archives\/548","title":{"rendered":"Setting variables across tasks in capistrano"},"content":{"rendered":"<p>I am learning to love <a href=\"http:\/\/www.capify.org\/\">capistrano<\/a>&#8211;it&#8217;s a fantastic deployment system for remote server management.\u00a0 I&#8217;m even learning enough ruby to be dangerous.<\/p>\n<p>One of the issues I ran into was I wanted to set a variable in one task and use it in another (or, more likely, in more than one other task).\u00a0 I couldn&#8217;t find any examples of how to do this online, so here&#8217;s how I did it:<\/p>\n<p><code> <\/code><\/p>\n<pre>task :set_var\r\nself[:myvar]= localvar\r\nend\r\n\r\ntask :read_var\r\nputs self[:myvar]\r\nend<\/pre>\n<p>Note that myvar and localvar need to be different identifiers&#8211;<a href=\"http:\/\/www.capify.org\/index.php\/Set\">&#8220;local variables take precedence&#8221;<\/a>.\u00a0 Also, the variable can be anything, I think.\u00a0 I use this method to create an array in one task, then iterate over it in another.<\/p>\n<p>[tags]capistrano, remote deployment, ruby newbie[\/tags]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am learning to love capistrano&#8211;it&#8217;s a fantastic deployment system for remote server management.\u00a0 I&#8217;m even learning enough ruby to be dangerous. One of the issues I ran into was [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39,37,20],"tags":[],"class_list":["post-548","post","type-post","status-publish","format-standard","hentry","category-cloud-computing","category-tips","category-web-applications"],"_links":{"self":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/548","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/comments?post=548"}],"version-history":[{"count":0,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/548\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/media?parent=548"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/categories?post=548"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/tags?post=548"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}