@@ -11,6 +11,7 @@ import org.tmatesoft.svn.core.SVNDirEntry
1111import org.tmatesoft.svn.core.SVNException
1212import org.tmatesoft.svn.core.SVNURL
1313import org.tmatesoft.svn.core.auth.BasicAuthenticationManager
14+ import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager
1415import org.tmatesoft.svn.core.auth.SVNAuthentication
1516import org.tmatesoft.svn.core.wc.*
1617
@@ -182,19 +183,38 @@ class SVNInfoService implements SCMInfoService {
182183 */
183184 protected static SVNClientManager getClientManager (VersioningExtension extension ) {
184185 def clientManager = SVNClientManager . newInstance()
186+ ISVNAuthenticationManager authenticationManager
185187 if (extension. user && extension. password) {
186188 LOGGER . info(" [version] Authenticating with ${ extension.user} " )
187- clientManager . setAuthenticationManager (BasicAuthenticationManager . newInstance(extension. user, extension. password. toCharArray()))
189+ authenticationManager = configureProxy (BasicAuthenticationManager . newInstance(extension. user, extension. password. toCharArray()))
188190 // The BasicAuthenticationManager trusts the certificates by default
189191 } else if (extension. trustServerCert) {
190192 LOGGER . info(" [version] Trusting certificate by default" )
191193 LOGGER . warn(" [version] WARNING The `trustServerCert` is now deprecated - and should not be used any longer." )
192- clientManager . setAuthenticationManager (BasicAuthenticationManager . newInstance(new SVNAuthentication [0 ]))
194+ authenticationManager = configureProxy (BasicAuthenticationManager . newInstance(new SVNAuthentication [0 ]))
193195 } else {
194196 LOGGER . info(" [version] Using default SVN configuration" )
195- clientManager . setAuthenticationManager( SVNWCUtil . createDefaultAuthenticationManager() )
197+ authenticationManager = SVNWCUtil . createDefaultAuthenticationManager()
196198 }
199+ clientManager. setAuthenticationManager(authenticationManager)
197200 return clientManager
198201 }
199202
203+ private static BasicAuthenticationManager configureProxy (BasicAuthenticationManager authenticationManager ) {
204+ def properties= System . properties
205+ def proxyHost = properties. getProperty(' http.proxyHost' )
206+ def proxyPort = properties. getProperty(' http.proxyPort' )
207+ def proxyUser = properties. getProperty(' http.proxyUser' )
208+ def proxyPassword = properties. getProperty(' http.proxyPassword' )
209+ if (proxyHost != null && proxyPort != null ) {
210+ if (proxyUser != null && proxyPassword != null ) {
211+ authenticationManager. setProxy(proxyHost, proxyPort as int , proxyUser, proxyPassword. toCharArray())
212+ } else {
213+ authenticationManager. setProxy(proxyHost, proxyPort as int , null , [] as char [])
214+ }
215+ }
216+
217+ return authenticationManager
218+ }
219+
200220}
0 commit comments