1 / 10

Scripting with Perforce Prakash Ranade

Scripting with Perforce Prakash Ranade. The P4 Command-Line Client. P4 CLI offers access to all Perforce features. It can used in scripts and is the ideal interface for automated processes such as backups and nightly builds.

zelda
Télécharger la présentation

Scripting with Perforce Prakash Ranade

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Scripting with PerforcePrakash Ranade

  2. The P4 Command-Line Client • P4 CLI offers access to all Perforce features. It can used in scripts and is the ideal interface for automated processes such as backups and nightly builds. • Custom automation of your development and administrative processes can be accomplished by embedding the appropriate commands in Perl, Python, or any other scripting language.

  3. The P4 Command-Line Client • P4 CLI uses the same commands and syntax on more than 50 platforms, and automatically translates line ending conventions between operating systems. • Generate custom reports from the Perforce metadata

  4. The Perforce Perl Scripting • The Perforce Perl API allows you to write Perl scripts that directly execute Perforce commands. • P4Perl is the product name for a Perl module that allows you to execute Perforce commands without leaving Perl space and to get the results in Perl Arrays and Hashes.

  5. P4Perl- Perl Extensions • #!/usr/bin/perl • use P4; • # Initialisation • my $p4 = new P4; • $p4->Init() or die( "Failed to connect to Perforce" ); • # Running "p4 info" and getting the results in array form • my @info; • @info = $p4->Info(); • # Submitting changes. Use "p4 change -o" to grab the change spec • # and "p4 submit -i" to do the submit. • # • # Commented out by default to make the example non-invasive • my $change = $p4->FetchChange(); • $change =~ s/<enter description here>/Some description/; • $p4->SetInput( $change ); • $p4->Submit( "-i" ) );

  6. NetApp environment • We are into development of storage and networking products. • Number of users: Approximately 800. • Number of development sites: 5 (main development center in Sunnyvale, California; remote US-based development sites in Pittsburgh, RTP, NANE, and Bangalore, India) • Perforce Proxy: Used in India, Pittsburgh offices • Status: In production; All development files are on our NetApp storage systems (for main server only).

  7. Scripting Advantages • Using scripting one can force the company specific rules. Examples… • Access control on depots • Branching strategy (cold, frozen, open) • Submit message check and integration with bug tracking system

  8. Scripting at Bangalore site • P4P PROXY site • P4PORT defined based on site • Simple checks for P4CLIENT definitions • Enforce rule based on site.

  9. How we did it!!! • /usr/local/bin/p4 wrapper perl script will manage p4 interactions on heterogeneous systems using platform dependant p4 binaries. • All Perforce users will use wrapper script. • Wrapper script does the argument processing, Access control, branching checks and executes p4 binary.

  10. Checks at remote sites tight views • //depot/prod/XXX/YYY/… checks using tight views. • XXX is product • YYY is code-line • Define client views (and branch and label views) so users access only the files they require. For example, the following "tight" client view is restricted to specific depot areas: • //depot/main/svr/devA/... //ws/main/svr/devA/... //depot/main/dvr/lport/... //ws/main/dvr/lport/... //depot/rel2.0/svr/devA/bin/... //ws/rel2.0/svr/devA/bin/... //depot/qa/s6test/dvr/... //ws/qa/s6test/dvr/... • By contrast, the following unrestricted view is easier to set up but invites trouble when depots are very large: //depot/... //ws/... • Client views, branch views, and label views are defined using the p4 client, p4 branch, and p4 label commands, respectively, by the users who created them.

More Related