我已經設置了一個mvn exec插件執行,它運行需要Nokogiri的Ruby腳本。 Jenkins作業是爲了構建Java項目而創建的。這個Ruby腳本應該運行在Maven構建的generate-sources階段。Nokogiri loadError僅在Jenkins作業
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<workingDirectory>src/main/resources</workingDirectory>
<arguments>
<argument>../../../test.rb</argument>
<argument>test.txt</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>/usr/local/rvm/rubies/ruby-2.1.5/bin/ruby</executable>
</configuration>
</plugin>
我對詹金斯箱安裝引入nokogiri,當我運行Ruby腳本詹金斯之外它工作正常,但是當詹金斯構建觸發它失敗:
/usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in
需要「:無法加載這樣的文件 - nokogiri(LoadError)from /usr/local/rvm/rubies-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in`require '
我的Ruby腳本:
require 'nokogiri'
if ARGV.size == 0
abort("Please provide the file name as first argument!")
end
ARGV.each { |input_file|
output_file = "_#{input_file}"
puts "Processing --- #{input_file} -> #{output_file}"
f = File.open(input_file)
doc = Nokogiri::XML(f)
##Move style tag to top of the body content
style = doc.at_css "style"
body = doc.at_css "body"
style.parent = body
first_child = body.first_element_child
first_child.add_previous_sibling(style)
File.open(output_file, "w") do |fout|
fout.puts doc.to_html
end
}
詹金斯無法加載Nokogiri,而詹金斯之外這個腳本工作正常。
您是否嘗試將RVL添加到PATH?像'export PATH =「$ PATH:$ HOME/.rvm/bin」' – stanjer
ya ..下面是在PATH中'/usr/local/rvm/gems/ruby-2.1.5/bin:/usr/local /rvm/gems/[email protected]/bin:/usr/local/rvm/rubies/ruby-2.1.5/bin' –
我在這裏看不到rmv的路徑,只能用於ruby ..無論如何nokogiri下載的地方並安裝? – stanjer