code: public BuildWithDetails triggerJobAndWaitUntilFinished(String jobName, boolean crumbFlag)
              throws IOException, InterruptedException {
          JobWithDetails job = this.server.getJob(jobName);
          QueueReference queueRef = job.build(crumbFlag);
  
          return triggerJobAndWaitUntilFinished(jobName, queueRef);
      }
docs: This method will trigger a build of the given job and will wait until the
  builds is ended or if the build has been cancelled.
  
  @param jobName The name of the job which should be triggered.
  @param crumbFlag set to <code>true</code> or <code>false</code>.
  @return In case of an cancelled job you will get
  {@link BuildWithDetails#getResult()}
  {@link BuildResult#CANCELLED}. So you have to check first if the
  build result is {@code CANCELLED}.
  @throws IOException in case of errors.
  @throws InterruptedException In case of interrupts.