MOTOSHARE 🚗🏍️
Turning Idle Vehicles into Shared Rides & Earnings

From Idle to Income. From Parked to Purpose.
Earn by Sharing, Ride by Renting.
Where Owners Earn, Riders Move.
Owners Earn. Riders Move. Motoshare Connects.

With Motoshare, every parked vehicle finds a purpose. Owners earn. Renters ride.
🚀 Everyone wins.

Start Your Journey with Motoshare

How to set latest P4 CL# into property?

tpatil created the topic: How to set latest P4 CL# into property?
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

How to set latest P4 CL# into property?
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
Twitt me @ twitter.com/RajeshKumarIn

tpatil replied the topic: Re:How to set latest P4 CL# into property?
/**
*Usage in pon.xml
* * test.maven
* maven-p4-plugin
*
*
*
* p4changes
*

*
* //depot/ABC/2/X/...
*

*

*

*
*
* 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();
}
}
}

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x