我是Ant脚本的新手。我正在尝试使用Ant脚本从SVN存储库中签出。下面是我的Ant脚本。
我在用詹金斯。创建了一个新项目,并在给定ant文件路径的情况下设置invoke-ant-build(ant目标是dist)。
我能够通过根用户签出代码&能够在Jenkinstools(源代码管理)中做到这一点。但是,当从Jenkins->Ant脚本构建执行时,它显示了以下错误:
服务器证书验证失败:为不同主机名颁发的证书,颁发者不受信任
<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>
正确有效的解决方案是使用与用于访问远程服务器的FQDN或主机名匹配的有效证书。所有其他建议都只是权宜之计,而且有点难看。您不应该绕过证书验证,因为从安全角度来看,它非常糟糕。