Example #1
0
 /**
  * Method for checking whether current build is sub job(MatrixRun) of Matrix build.
  *
  * @return boolean
  */
 public boolean isMatrixRun() {
   StaplerRequest request = Stapler.getCurrentRequest();
   if (request != null) {
     build = request.findAncestorObject(AbstractBuild.class);
     if (build != null && build instanceof MatrixRun) {
       return true;
     }
   }
   return false;
 }
Example #2
0
 /**
  * Method will return current project.
  *
  * @return currentProject.
  */
 public AbstractProject getProject() {
   if (build != null) {
     return build.getProject();
   }
   AbstractProject currentProject = null;
   StaplerRequest request = Stapler.getCurrentRequest();
   if (request != null) {
     currentProject = request.findAncestorObject(AbstractProject.class);
   }
   if (currentProject == null) {
     throw new NullPointerException("Current Project is null");
   }
   return currentProject;
 }