Welcome, Guest
Username Password: Remember me

How to set latest P4 CL# into property?
(1 viewing) (1) Guest
Maven
  • Page:
  • 1

TOPIC: How to set latest P4 CL# into property?

How to set latest P4 CL# into property? 1 year, 10 months ago #294

  • tpatil
  • OFFLINE
  • Junior Boarder
  • Posts: 27
  • Points: 5111
  • Karma: 0
  • Honor Medal 2009
We have CI setup using bamboo, P4 & maven. When I trigger the build from bamboo it gives me the CL# on which the build is done on build results page.

How can I get this value/property in pom.xml? I want to add to this CL# to MANIFEST.MF file.


Thanks,
-Tushar

Re:How to set latest P4 CL# into property? 1 year, 10 months ago #296

  • rajeshkumar
  • OFFLINE
  • Moderator
  • I love software configuration management
  • Posts: 370
  • Points: 44630
  • Karma: 4
  • Honor Medal 2009
This may serve your ur purpose...
p4 changes -s submitted -m1

plz refer following articles as well

stackoverflow.com/questions/47007/determ...ynced-to-in-perforce
Regards,
Rajesh Kumar
Build and Release Engineer
My Blog: community.scmgalaxy.com/pg/profile/rajeshkumar

Re:How to set latest P4 CL# into property? 1 year, 10 months ago #301

  • tpatil
  • OFFLINE
  • Junior Boarder
  • Posts: 27
  • Points: 5111
  • Karma: 0
  • Honor Medal 2009
/**
*Usage in pon.xml
* <plugin>
* <groupId>test.maven</groupId>
* <artifactId>maven-p4-plugin</artifactId>
* <executions>
* <execution>
* <goals>
* <goal>p4changes</goal>
* </goals>
* <configuration>
* <url>//depot/ABC/2/X/...</url>
* </configuration>
* </execution>
* </executions>
* </plugin>
*
* Goal which touches a timestamp file.
*
* @goal p4changes
*
* @phase process-sources
*/
public class P4RevisionMojo extends AbstractMojo {

private Process p;
private Properties prop;
private MavenProject project;
/**
* @parameter expression="${p4.url}" default-value="./..."
* @required
* @since 1.0
*/
private String suffix;
/**
* @parameter expression="${p4.port}" default-value="${env.P4PORT}"
* @optional
* @since 1.0
*/
private String p4port;
/**
* @parameter expression="${p4.client}" default-value="${env.P4CLIENT}"
* @optional
* @since 1.0
*/
private String p4client;
/**
* @parameter expression="${p4.user}" default-value="${env.P4USER}"
* @optional
* @since 1.0
*/
private String p4user;
/**
* @parameter expression="${p4.passwd}" default-value="${env.P4PASSWD}"
* @optional
* @since 1.0
*/
private String p4passwd;

public void execute() throws MojoExecutionException {
try {
String cmd = "p4 changes -m 1 " + url;
this.getLog().info("Executing P4 command: " + cmd);
p = Runtime.getRuntime().exec(cmd);
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = stdInput.readLine();

String property = "p4.revision";
if (suffix != null && suffix.length() > 0) {
property = property.concat("." + suffix);
}

prop.setProperty("buildtstamp", new Date().toString());
prop.setProperty(property, "000000");
while (line != null) {
String[] line_items = line.split(" ");
if (line_items.length >= 1) {
if (line_items[0].equalsIgnoreCase("Change")) {
prop.setProperty(property, line_items[1]);
this.getLog().info("P4 Revision ${" + property + "} :::: " + prop.getProperty(property));
}

}
return;
}


} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
  • Page:
  • 1
Time to create page: 0.66 seconds

     
    
Home Forum