我正在尝试使用chef安装OpenJDK,以及下载
Eclipse并在Windows 2008节点上使用p2 director安装一些插件. OpenJDK安装并设置我的环境变量JAVA_HOME并将其添加到路径中.
但是,在我关闭并重新打开PowerShell之前,此更改不会生效.厨师 – 客户端运行需要在当前会话中运行eclipse p2导演.有没有办法做到这一点,我只能运行一次厨师 – 客户?
但是,在我关闭并重新打开PowerShell之前,此更改不会生效.厨师 – 客户端运行需要在当前会话中运行eclipse p2导演.有没有办法做到这一点,我只能运行一次厨师 – 客户?
env "JAVA_HOME" do value 'C:\\Program Files\\Zulu\\zulu-8' end env "path" do delim ";" value '%JAVA_HOME%\\bin' action :modify end #For Command Prompt execute "setPathCMD" do command "set PATH=#{node['java']['path']}\\bin;%PATH%" end #For PowerShell powershell_script "setPathPS" do code <<-EOH $env:Path="#{node['java']['path']}\\bin;$env:Path" EOH end ENV['Path'] += ";C:\\Program Files\\Zulu\\zulu-8\\bin"
if not node['eclipse']['plugins'].empty? node['eclipse']['plugins'].each do |plugin_group| repo,id = plugin_group.first execute "eclipse plugin install" do command "#{node['eclipse']['unzip_location']}/eclipse/eclipse.exe -application org.eclipse.equinox.p2.director -noSplash -repository #{repo} -installIUs #{id}" action :run end end end
解决方法
尝试使用setx:
execute 'set java_home' do command "setx -m JAVA_HOME \"C:\\Program Files\\Zulu\\zulu-8\"" only_if { ENV['JAVA_HOME'] != 'C:\\Program Files\\Zulu\\zulu-8' } end # Set JAVA_HOME for this process ENV['JAVA_HOME'] = 'C:\\Program Files\\Zulu\\zulu-8' # do something similar for path...
改编自visualstudio cookbook,用于启用NuGet包恢复:
https://github.com/daptiv/visualstudio/blob/master/recipes/nuget.rb