开发者

Can you do this with Hudson?

I want to create a hudson job, that takes an id as a parameter. And use that id to calculate the svn-repo path.

Where I work you have a svn path for every issue that you resolve. And then all the issues are joined into a single svn-path.

What I want to do is to run static code analysis on the partial issues.

So I think maybe having an Ant build.xml that I use for every issue, then, parametrize the job with the issue id.

I have tried to achieve that but the svn path doesn't replace the parameter.

I have tried with #issueId, %issueId%, ${issueId} and ${env.issueId} without success.

Jump error like:

Location 'http://svn-path:8181/svn/devSet/issues/${env.chuid}' does not exist
Checking out a fresh workspace because C:\Documents and Settings\dnoseda\.hudson\jobs\test\workspace\${env.chuid} doesn't exist
Checking out http://svn-path:8181/svn/d开发者_高级运维evSet/issues/${env.chuid}
ERROR: Failed to check out http://svn-path:8181/svn/devSet/issues/${env.chuid}
org.tmatesoft.svn.core.SVNException: svn: '/svn/!svn/bc/46190/devSet/issues/$%7Benv.chuid%7D' path not found: 404 Not Found (http://svn-path:8181)
    at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:64)
    at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:51)
    at 

I am think that I can not do what I want.

Do you know how I can setup the correct configuration to achieve this matter?

Thanks for any help.

Edit The section of the configurate job that I want to put this parameter is this:

<scm class="hudson.scm.SubversionSCM">
<locations>
      <hudson.scm.SubversionSCM_-ModuleLocation>
        <remote>http://svn-path:8181/svn/devSet/issues/${env.issueid}</remote>
      </hudson.scm.SubversionSCM_-ModuleLocation>
    </locations>

New Edit: Solved

My version of hudson it was the last (1.349), but the version of svn plugin it was 1.11, being the last the 1.13, and it work with ${issueId}

Thank for the anwsers


From the hudson wiki:

"The parameter are available as environment parameters. So e.g. a shell ($FOO, %FOO%) or Ant ( ${env.FOO} ) can access these values."

Your syntax doesn't match the one in the wiki.


I've setup a svn project that does the parameter substitution successfully. The syntax is indeed ${issueId} so I assume you are doing something wrong, or are using a very old version of Hudson. Could you update the question with the versions of Hudson and the subversion plugin that you are using?

<project> 
  <actions/> 
  <description></description> 
  <keepDependencies>false</keepDependencies> 
  <properties> 
    <hudson.model.ParametersDefinitionProperty> 
      <parameterDefinitions> 
        <hudson.model.StringParameterDefinition> 
          <name>issueId</name> 
          <description></description> 
          <defaultValue>none</defaultValue> 
        </hudson.model.StringParameterDefinition> 
      </parameterDefinitions> 
    </hudson.model.ParametersDefinitionProperty> 
  </properties> 
  <scm class="hudson.scm.SubversionSCM"> 
    <locations> 
      <hudson.scm.SubversionSCM_-ModuleLocation> 
        <remote>https://svn.dev.java.net/svn/hudson/trunk/${issueId}</remote> 
      </hudson.scm.SubversionSCM_-ModuleLocation> 
    </locations> 
    <useUpdate>true</useUpdate> 
    <excludedRegions></excludedRegions> 
    <excludedUsers></excludedUsers> 
    <excludedRevprop></excludedRevprop> 
  </scm> 
  <canRoam>true</canRoam> 
  <disabled>false</disabled> 
  <triggers class="vector"/> 
  <concurrentBuild>false</concurrentBuild> 
  <builders/> 
  <publishers/> 
  <buildWrappers/> 
</project>

Here is the build output. The checkout fails due to an authentication issue, but the parameter is successfully replaced:

Started by user anonymous
Building on master
Checking out a fresh workspace because C:\hudson\jobs\test-svn\workspace\${issueId} doesn't exist
Checking out https://svn.dev.java.net/svn/hudson/trunk/www
ERROR: Failed to check out https://svn.dev.java.net/svn/hudson/trunk/www
org.tmatesoft.svn.core.SVNCancelException: svn: No credential to try. Authentication failed
    at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.cancel(SVNErrorManager.java:37)
    at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.cancel(SVNErrorManager.java:32)
    at org.tmatesoft.svn.core.internal.wc.DefaultSVNAuthenticationManager.getFirstAuthentication(DefaultSVNAuthenticationManager.java:168)
    at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:534)
    at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:273)
    at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:261)
    at org.tmatesoft.svn.core.internal.io.dav.DAVConnection.exchangeCapabilities(DAVConnection.java:516)
    at org.tmatesoft.svn.core.internal.io.dav.DAVConnection.open(DAVConnection.java:98)
    at org.tmatesoft.svn.core.internal.io.dav.DAVRepository.openConnection(DAVRepository.java:1001)
    at org.tmatesoft.svn.core.internal.io.dav.DAVRepository.getLatestRevision(DAVRepository.java:178)
    at org.tmatesoft.svn.core.wc.SVNBasicClient.getRevisionNumber(SVNBasicClient.java:482)
    at org.tmatesoft.svn.core.wc.SVNBasicClient.getLocations(SVNBasicClient.java:851)
    at org.tmatesoft.svn.core.wc.SVNBasicClient.createRepository(SVNBasicClient.java:534)
    at org.tmatesoft.svn.core.wc.SVNUpdateClient.doCheckout(SVNUpdateClient.java:893)
    at org.tmatesoft.svn.core.wc.SVNUpdateClient.doCheckout(SVNUpdateClient.java:791)
    at hudson.scm.SubversionSCM$CheckOutTask.invoke(SubversionSCM.java:615)
    at hudson.scm.SubversionSCM$CheckOutTask.invoke(SubversionSCM.java:541)
    at hudson.FilePath.act(FilePath.java:676)
    at hudson.FilePath.act(FilePath.java:660)
    at hudson.scm.SubversionSCM.checkout(SubversionSCM.java:534)
    at hudson.scm.SubversionSCM.checkout(SubversionSCM.java:482)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:898)
    at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:400)
    at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:349)
    at hudson.model.Run.run(Run.java:1106)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:93)
    at hudson.model.Executor.run(Executor.java:122)
Notifying upstream projects of job completion
Finished: FAILURE


In this comment, it is mentioned that they use the ${ISSUEID}, which is why I suggested it, but all other signs I see say this doesn't actually work.

Otherwise I would recommend not using the SCM plugin and doing the SVN operation in a build script step. This would allow you to use the parameters as env variables like $ISSUEID

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜