2016-06-09 62 views
-1

我是Ant腳本編程新手。我正在嘗試使用Ant腳本從SVN存儲庫中籤出。請在下面找到我的Ant腳本。使用SvnAnt在SVN結帳時出現「驗證服務器證書錯誤」

我正在使用詹金斯。創建一個新項目,並設置調用ant構建給定螞蟻文件的路徑(ant target is dist)。

我能夠通過root用戶&簽出代碼,可以在Jenkinstools(源代碼管理)中執行此操作。不過,雖然從詹金斯執行 - > Ant腳本構建,它顯示了以下錯誤:

Server certificate verification failed: certificate issued for a different hostname, issuer is not trusted

<project name="ProjectBuid" basedir="."> 

<description> 
    simple example build file 
</description> 
<property environment="env" /> 
<property name="svn.username" value="NANI" /> 
<property name="svn.password" value="Pandu" /> 
<property name="code.base.location" value="${env.WORKSPACE}" /> 
<property name="lib.home" value="..\lib" /> 
<property name="{svnPathParam}" value="https://Ip:port/Build/" /> 

<property name="jenkins-url" value="http://IP1" /> 
<property name="auth-username" value="root" /> 
<property name="auth-pwd" value="1231231231231" /> 
<property name="cli.prefix" value="AB_CLI_" /> 

<path id="mvn.classpath"> 
    <pathelement location="${lib.home}\maven-ant-tasks-2.1.3.jar" /> 
</path> 
<path id="svnant.classpath"> 
    <pathelement location="${lib.home}\svnant.jar" /> 
    <pathelement location="${lib.home}\svnClientAdapter.jar" /> 
    <pathelement location="${lib.home}\svnkit.jar" /> 
    <pathelement location="${lib.home}\ganymed.jar" /> 
    <pathelement location="${lib.home}\svnjavahl.jar" /> 
</path> 

<tstamp> 
    <format property="START_TIME" pattern="dd_MMM_yy_HH_mm_ss" /> 
</tstamp> 
<property name="timestamp" value="${START_TIME}" /> 
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask" 
    classpath="${lib.home}\xmltask.jar" /> 
<taskdef resource="net/sf/antcontrib/antcontrib.properties"> 
    <classpath> 
     <pathelement location="${lib.home}\ant-contrib-1.0b3.jar" /> 
    </classpath> 
</taskdef> 

<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" 
    classpathref="svnant.classpath" /> 
<svnSetting svnkit="false" javahl="false" id="svn.settings" 
    username="${svn.username}" password="${svn.password}" /> 

<target name="dist" description="checkout code"> 
    <mkdir dir="${code.base.location}/${timestamp}" /> 
    <exec dir="${code.base.location}/${timestamp}" executable="svn"> 
     <arg value="co" /> 
     <arg value="${svnPathParam}" /> 
     <arg value="." /> 
    </exec> 
    <!-- On executing above, error: Error validating server certificate for 
     'https://IP': [exec] - The certificate is not issued by a trusted authority. 
     Use the [exec] fingerprint to validate the certificate manually! [exec] - 
     The certificate hostname does not match. [exec] Certificate information: 
     [exec] - Hostname: IP [exec] - Valid: from XXXXXXX until yyyyyyyyyyyy [exec] 
     - Issuer: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX [exec] - Fingerprint: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 
     [exec] (R)eject, accept (t)emporarily or accept (p)ermanently? svn: OPTIONS 
     of 'https://Ip/build': Server certificate verification failed: certificate 
     issued for a different hostname, issuer is not trusted (https://IP) <!--Or 
     and also tried as below --> 
    <svn refid="svn.settings"> 
     <checkout url="${svnPathParam}" destPath="${code.base.location}\${timestamp}" /> 
    </svn> 
    <!-- On choosing above, error: svn: OPTIONS of 'https://Ip/build': Server 
     certificate verification failed: certificate issued for a different hostname, 
     issuer is not trusted (https://IP) [svn] <Checkout> failed. --> 
</target> 

+0

您是否試圖通過其IP而不是主機名來訪問https站點?但是..你能不能以正確的用戶手動運行'svn co'並永久接受證書? – Roberg

+0

[在subversion中繞過ssl證書驗證]可能重複(http://stackoverflow.com/questions/9257323/bypass-ssl-certificate-validation-in-subversion) – Rao

+0

如果您使用Jenkins,您是否考慮過配置構建工作做結帳,而不是從ANT內部運行它?如果你希望所有的配置都在本地,新的Jenkins管道功能可以讓你在「Jenkinsfile」中保持構建作業配置。請參閱:https://jenkins.io/solutions/pipeline/ –

回答

0

的適當和有效的解決方案是使用您使用的FQDN或主機名匹配的有效證書訪問遠程服務器。所有其他建議都只是解決方法,它們有點難看。您不應該繞過證書驗證,因爲從安全角度來看它非常糟糕。

相關問題