String jobName = environment.get("PROMOTED_JOB_NAME");
String buildNumber = environment.get("PROMOTED_NUMBER");
if(jobName == null || jobName.isEmpty() || buildNumber == null || buildNumber.isEmpty()){
listener.getLogger().println("Not a promotion job.");
} else {
AbstractProject project = (AbstractProject) Hudson.getInstance().getItemByFullName(jobName, AbstractProject.class);
int buildNum = Integer.parseInt(buildNumber);
build = (AbstractBuild<?, ?>) project.getBuildByNumber(buildNum);
tagAction = (PerforceTagAction) build.getAction(PerforceTagAction.class);
}
if(tagAction == null){
listener.getLogger().println("Could not label build in perforce; is it a valid perforce job?");
return false;