2016-06-09 61 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或主机名匹配的有效证书访问远程服务器。所有其他建议都只是解决方法,它们有点难看。您不应该绕过证书验证,因为从安全角度来看它非常糟糕。

相关问题