Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Change ViewMapping in Perforce Repository with groovy #4187

Laba42 ·

I have a groovy script that I use to evaluate some JIRA issues via REST.
In each Jira Issue there can be a Perforce path.
Now I would like to iterate over all found Perforce Paths and check them out.

After I found this example here,
I tried the following

I create repository "P4-Migration-Files" with an initial mapping

In the first step I determine, with an groovy script, the used Perforce path.
and tried to change the view mapping

def path = "depot/path1/folder1/projektA/..."

def repo = repositories.get("P4-Migration-Files")
def spec = repo.staticSpecProvider.staticSpec

def view = "//" + path + " " + repo.getClientName() + "/" +  path
spec.setMappings(Mapping.parseView(repo, view))

and in the next step I added the Perforce CheckOut Step for the "P4-Migration-Files"
But this did not work, the new viewmapping was not used.

Is there a way I can change the view mapping of the repository object?

Georg

  • solved #2
  • replies 1
  • views 43
  • stars 0
robinshen ADMIN ·

Changing repository mapping on the fly while a build is running is not supported. A workaround is to change repository view of another configuration, and then trigger that configuration via "trigger build step". To change repository view of another configuration:

groovy:
import com.pmease.quickbuild.migration.VersionedDocument

def path = "depot/path1/folder1/projektA/..."
def otherConf = system.getConfiguration("path/to/otherConf");
def repo = otherConf.getRepository("P4-Migration-Files")
repo.staticSpecProvider.view = "//" + path + " " + repo.getClientName() + "/" + path
otherConf.repositoryDOMs[repo.name] = VersionedDocument.fromBean(repo)
system.configurationManager.save(otherConf)