Accessing perforce settings on agent (ant build)

Hi,

is there a way to get the perforce settings on the agent (running an ant build script) ?

In order to generate a build description for Escrow builds (http://en.wikipedia.org/wiki/Source_code_escrow)
we need to include all information that is necessary to extract the sources from perforce
using the changelist number (which we got as the team city build number) plus the perforce
client mapping (workspace). The agent could query it's own configuration setting (VCS root) but when
P4 Connection Settings is specified using      "Client:"  the agent would need to login to perforce to
extract the workspace...

Any ideas on this would be great...

Stefan

2 comments
Comment actions Permalink

Hello Stefan,

  The only thing I can think of by the moment is to write a TeamCity server-side plugin which implements TeamCity extension jetbrains.buildServer.serverSide.ParametersPreprocessor to pass this information as a system property to build agent.

  To get mapping information in the preprocessor, ask SRunningBuild (this is not production code, just a hint how to obtain info):
  build.getBuildType().getVcsRoots().get(0).getProperty("client-mapping")
  You can put this value to buildParameters map under some key:  params.put("env.VCS_MAPPING", value), in this case the mapping should be available to your build via VCS_MAPPING environment variable.

  Kind regards,
  KIR

0
Comment actions Permalink

Hi Kirill,

thanks for the instructions on how to do this.

I've now written a server-side plugin that reads the "client" property and runs p4.exe to extract the full workspace definition.
This is then added as a string with key "system.build.tomtec.perforce.workspace"

I now have the problem that it works on all windows agents, but linux gives me an error "is not fully resolved, using as is" in the build log:

[10:55:15]: Checking for changes
[10:55:16]: Clearing temporary directory: /home/users/buildagent/agent/temp/buildTmp
[10:55:16]: Checkout directory: /home/users/buildagent/agent/work/4e8672b90b0fba5f
[10:55:16]: Updating sources (5s)
[10:55:16]: [Updating sources] Building incremental patch for VCS root: TeamCity-TestWorkspace
[10:55:21]: [Updating sources] Repository sources transferred: 30.10Kb total
[10:55:21]: [Updating sources] Updating /home/users/buildagent/agent/work/4e8672b90b0fba5f

[10:55:22]:
Parameter 'system.build.tomtec.perforce.workspace=# A Perforce Client Specification.
#  Client:      The client name.
#  Update:      The date this specification was last modified.
#  Access:      The date this client was last used in any way.
..and so on
' is not fully resolved, using as is.

[10:55:22]: Ant JUnit report watcher



The property can be used but I would like to have an error-free build log. Is there some limitation on what strings can be passed as properties ?

Thanks,

Stefan

0

Please sign in to leave a comment.