title: Maven Metadata Plugin unable to get the maven-metadata.xml due to java.net.UnknownHostException
body: <p>I have been trying to configure a Jenkins Job for the deployment task of Java artifacts. I want the user to be able to select the artifact version to be deployed which are stored in Nexus repository. For this I'm using the Maven Metadata Plugin to get the list of artifact versions from the repository. </p>
  
  <p>The problem is, Jenkins server is unable to resolve the Repository Base URL (<a href="https://nexus.repos.prod.com/nexus/content/groups/prod-pds-releases-all" rel="nofollow">https://nexus.repos.prod.com/nexus/content/groups/prod-pds-releases-all</a>) due to 
  java.net.UnknownHostException</p>
  
  <p>Below is the stack trace:</p>
  
  <pre><code>01-Jul-2015 15:45:34.460 WARNING [Handling GET /jenkins/job/Prod_PDS_Deploy/build from 10.11.131.69 : http-nio-9091-exec-9 ParametersDefinitionProperty/index.jelly MavenMetadataParameterDefinition/index.jelly] null.null Could not parse maven-metadata.xml
   java.net.UnknownHostException: nexus.repos.prod.com
          at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
          at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
          at java.net.Socket.connect(Socket.java:589)
          at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:656)
          at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173)
          at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
          at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
          at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
          at sun.net.www.protocol.https.HttpsClient.&lt;init&gt;(HttpsClient.java:275)
          at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:371)
          at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
          at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1104)
          at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:998)
          at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
          at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1512)
          at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1440)
          at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
          at eu.markov.jenkins.plugin.mvnmeta.MavenMetadataParameterDefinition.getArtifactMetadata(MavenMetadataParameterDefinition.java:196)
          at eu.markov.jenkins.plugin.mvnmeta.MavenMetadataParameterDefinition.getVersions(MavenMetadataParameterDefinition.java:187)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:497)
          at org.apache.commons.jexl.util.PropertyExecutor.execute(PropertyExecutor.java:125)
          at org.apache.commons.jexl.util.introspection.UberspectImpl$VelGetterImpl.invoke(UberspectImpl.java:314)
          at org.apache.commons.jexl.parser.ASTArrayAccess.evaluateExpr(ASTArrayAccess.java:185)
          at org.apache.commons.jexl.parser.ASTIdentifier.execute(ASTIdentifier.java:75)
          at org.apache.commons.jexl.parser.ASTReference.execute(ASTReference.java:83)
          at org.apache.commons.jexl.parser.ASTReference.value(ASTReference.java:57)
          at org.apache.commons.jexl.parser.ASTReferenceExpression.value(ASTReferenceExpression.java:51)
          at org.apache.commons.jexl.ExpressionImpl.evaluate(ExpressionImpl.java:80)
          at hudson.ExpressionFactory2$JexlExpression.evaluate(ExpressionFactory2.java:74)
          at org.apache.commons.jelly.expression.ExpressionSupport.evaluateRecurse(ExpressionSupport.java:61)
          at org.apache.commons.jelly.expression.ExpressionSupport.evaluateAsIterator(ExpressionSupport.java:94)
          at org.apache.commons.jelly.tags.core.ForEachTag.doTag(ForEachTag.java:89)
          at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
          at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
          at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:161)
          at org.apache.commons.jelly.tags.core.OtherwiseTag.doTag(OtherwiseTag.java:41)
          at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
          at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
          at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:161)
          at org.apache.commons.jelly.tags.core.ChooseTag.doTag(ChooseTag.java:38)
          at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
          at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
          at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
          at org.kohsuke.stapler.jelly.CallTagLibScript$1.run(CallTagLibScript.java:99)
          at org.apache.commons.jelly.tags.define.InvokeBodyTag.doTag(InvokeBodyTag.java:91)
          at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
          at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
          at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
          at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
          at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
          at org.apache.commons.jelly.tags.core.CoreTagLibrary$2.run(CoreTagLibrary.java:105)
          at org.kohsuke.stapler.jelly.CallTagLibScript.run(CallTagLibScript.java:120)
          at org.apache.commons.jelly.tags.core.CoreTagLibrary$2.run(CoreTagLibrary.java:105)
          at org.kohsuke.stapler.jelly.JellyViewScript.run(JellyViewScript.java:95)
          at org.kohsuke.stapler.jelly.IncludeTag.doTag(IncludeTag.java:147)
          at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
          at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
          at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:161)
          at org.apache.commons.jelly.tags.core.ForEachTag.doTag(ForEachTag.java:150)
          at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
          at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
          at org.kohsuke.stapler.jelly.CallTagLibScript$1.run(CallTagLibScript.java:99)
          at org.apache.commons.jelly.tags.define.InvokeBodyTag.doTag(InvokeBodyTag.java:91)
          at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
          at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
          at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
          at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
          at org.apache.commons.jelly.tags.core.CoreTagLibrary$2.run(CoreTagLibrary.java:105)
          at org.kohsuke.stapler.jelly.CallTagLibScript.run(CallTagLibScript.java:120)
          at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
          at org.kohsuke.stapler.jelly.CallTagLibScript$1.run(CallTagLibScript.java:99)
          at org.apache.commons.jelly.tags.define.InvokeBodyTag.doTag(InvokeBodyTag.java:91)
          at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
          at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
          at org.apache.commons.jelly.tags.core.CoreTagLibrary$1.run(CoreTagLibrary.java:98)
          at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
          at org.apache.commons.jelly.tags.core.CoreTagLibrary$2.run(CoreTagLibrary.java:105)
          at org.kohsuke.stapler.jelly.CallTagLibScript.run(CallTagLibScript.java:120)
          at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
          at org.kohsuke.stapler.jelly.CallTagLibScript$1.run(CallTagLibScript.java:99)
          at org.apache.commons.jelly.tags.define.InvokeBodyTag.doTag(InvokeBodyTag.java:91)
          at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
          at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
          at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
          at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
          at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
          at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
          at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
          at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
          at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
          at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
          at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99)
          at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
          at org.apache.commons.jelly.tags.core.CoreTagLibrary$2.run(CoreTagLibrary.java:105)
          at org.kohsuke.stapler.jelly.CallTagLibScript.run(CallTagLibScript.java:120)
          at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
          at org.apache.commons.jelly.tags.core.CoreTagLibrary$2.run(CoreTagLibrary.java:105)
          at org.kohsuke.stapler.jelly.JellyViewScript.run(JellyViewScript.java:95)
          at org.kohsuke.stapler.jelly.DefaultScriptInvoker.invokeScript(DefaultScriptInvoker.java:63)
          at org.kohsuke.stapler.jelly.DefaultScriptInvoker.invokeScript(DefaultScriptInvoker.java:53)
          at org.kohsuke.stapler.jelly.JellyRequestDispatcher.forward(JellyRequestDispatcher.java:55)
          at jenkins.model.ParameterizedJobMixIn.doBuild(ParameterizedJobMixIn.java:162)
          at hudson.model.AbstractProject.doBuild(AbstractProject.java:1757)
          at hudson.model.AbstractProject.doBuild(AbstractProject.java:1763)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:497)
          at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:298)
          at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:161)
          at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:96)
          at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:121)
          at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
          at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746)
          at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876)
          at org.kohsuke.stapler.MetaClass$6.doDispatch(MetaClass.java:249)
          at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
          at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746)
          at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876)
          at org.kohsuke.stapler.Stapler.invoke(Stapler.java:649)
          at org.kohsuke.stapler.Stapler.service(Stapler.java:238)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:123)
          at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:114)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:48)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
          at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
          at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
          at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:117)
          at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
          at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
          at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
          at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
          at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
          at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
          at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
          at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:93)
          at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
          at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
          at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67)
          at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
          at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76)
          at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:81)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:613)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
          at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516)
          at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1086)
          at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:659)
          at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
          at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1558)
          at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1515)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
          at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
          at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <p>I have tried to access the maven-metadata.xml url from the Jenkins Server machine using wget and successfully download the metadata! So there are no issues with the Jenkins server accessing nexus repository.</p>
  
  <pre><code>[jenkins@jenkinshost ~]$ wget --proxy-user="username" --proxy-password=$pwd https://nexus.repos.prod.com/nexus/content/groups/prod-pds-releases-all/com/prod/pds/pds-ear/maven-metadata.xml --user=$nexususer --password=$nexuspwd
  --2015-07-01 15:49:01--  https://nexus.repos.prod.com/nexus/content/groups/prod-pds-releases-all/com/prod/pds/pds-ear/maven-metadata.xml
  Resolving adproxy.hq.prod.com... 10.12.44.22, 10.13.14.16
  Connecting to adproxy.hq.prod.com|10.12.44.22|:8080... connected.
  Proxy request sent, awaiting response... 401 Unauthorized
  Connecting to adproxy.hq.prod.com|10.12.44.22|:8080... connected.
  Proxy request sent, awaiting response... 200 OK
  Length: 5863 (5.7K) [application/xml]
  Saving to: `maven-metadata.xml'
  100%[===========================================================================================================================================================================&gt;] 5,863       --.-K/s   in 0s
  </code></pre>
  
  <p>I'm struggling to understand why Jenkins is not able to resolve the nexus url when running the job whereas the same is accessible from command line! Is there a difference in the way Jenkins Maven Metadata plugin access the repository to that of accessing the repos directly using wget?</p>
  
  <p>I have setup the proxy host and port in the Jenkins Plugin Manager (Advanced) settings.
  But still Jenkins doesn't seem to use these values or expecting some other value to be set. </p>
  
  <p>On the Jenkins machine I have the environment properties http_proxy &amp; https_proxy defined in .bash_profile. Without these variables I get the same error (UnknownHost) even from command line using wget! So I suspect that these env properties are not getting set when Jenkins is trying to download the metadata xml. I would've thought Jenkins would use the same system properties but apparently not!</p>
  
  <p>That is the only difference I can think of between downloading the metadata xml manually from Jenkins machine using wget command and using Jenkins.</p>
  
  <p>Is there a way to set these properties http_proxy &amp; https_proxy before Jenkins tries to download the xml?</p>
  
  <p>Thanks.</p>