예제 #1
0
 protected RepositoryBrowser<T> getRepositoryBrowser() {
   if (build == null || build.getProject() == null) {
     return null;
   }
   final SCM scm = build.getProject().getScm();
   return scm.getBrowser();
 }
 private static String keyFor(
     @NonNull SCM scm,
     @NonNull FilePath ws,
     @Nullable AbstractBuild<?, ?> build) { // JENKINS-12298
   StringBuilder b = new StringBuilder(scm.getType());
   for (FilePath root : scm.getModuleRoots(ws, build)) {
     b.append(root.getRemote().substring(ws.getRemote().length()));
   }
   return b.toString();
 }
 public SCMRevisionState get(
     @NonNull SCM scm, @NonNull FilePath ws, @Nullable AbstractBuild<?, ?> build) {
   SCMRevisionState state = revisionStates.get(scm.getKey());
   if (state == null) {
     // backward compatibility with 0.2
     state = revisionStates.get(keyFor(scm, ws, build));
   }
   // for backward compatibility with version 0.1, try to get the state using the class name as
   // well
   if (state == null) state = revisionStates.get(scm.getClass().getName());
   return state;
 }
 public void add(
     @NonNull SCM scm,
     @NonNull FilePath ws,
     @Nullable Run<?, ?> build,
     SCMRevisionState scmState) {
   revisionStates.put(scm.getKey(), scmState);
 }
예제 #5
0
 public void buildEnvVars(AbstractBuild build, java.util.Map<String, String> env) {
   super.buildEnvVars(build, env);
   String branch = getSingleBranch(build);
   if (branch != null) {
     env.put(GIT_BRANCH, branch);
   }
 }
예제 #6
0
    private void checkout(BuildListener listener) throws Exception {
      try {
        for (int retryCount = project.getScmCheckoutRetryCount(); ; retryCount--) {
          // for historical reasons, null in the scm field means CVS, so we need to explicitly set
          // this to something
          // in case check out fails and leaves a broken changelog.xml behind.
          // see
          // http://www.nabble.com/CVSChangeLogSet.parse-yields-SAXParseExceptions-when-parsing-bad-*AccuRev*-changelog.xml-files-td22213663.html
          AbstractBuild.this.scm = new NullChangeLogParser();

          try {
            if (project.checkout(
                AbstractBuild.this, launcher, listener, new File(getRootDir(), "changelog.xml"))) {
              // check out succeeded
              SCM scm = project.getScm();

              AbstractBuild.this.scm = scm.createChangeLogParser();
              AbstractBuild.this.changeSet = AbstractBuild.this.calcChangeSet();

              for (SCMListener l : Hudson.getInstance().getSCMListeners())
                l.onChangeLogParsed(AbstractBuild.this, listener, changeSet);
              return;
            }
          } catch (AbortException e) {
            listener.error(e.getMessage());
          } catch (IOException e) {
            // checkout error not yet reported
            e.printStackTrace(listener.getLogger());
          }

          if (retryCount == 0) // all attempts failed
          throw new RunnerAbortedException();

          listener.getLogger().println("Retrying after 10 seconds");
          Thread.sleep(10000);
        }
      } catch (InterruptedException e) {
        listener.getLogger().println(Messages.AbstractProject_ScmAborted());
        LOGGER.log(Level.INFO, AbstractBuild.this + " aborted", e);
        throw new RunnerAbortedException();
      }
    }
예제 #7
0
 public static List<SCMDescriptor<?>> getSCMDescriptors(AbstractProject<?, ?> project) {
   return SCM._for(project);
 }