Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (C) 2012 JFrog Ltd.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *  http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.jfrog.hudson.release.scm.perforce;
 
 
Perforce scm coordinator. Interacts with the PerforceManager to fulfill the release process.

Author(s):
Yossi Shaul
 
 public class PerforceCoordinator extends AbstractScmCoordinator {
     private static Logger debuggingLogger = Logger.getLogger(PerforceManager.class.getName());
 
     private PerforceManager perforce;
     private final ReleaseAction releaseAction;
     private boolean tagCreated;
     private int currentChangeListId;
 
     public PerforceCoordinator(AbstractBuild buildBuildListener listenerReleaseAction releaseAction) {
         super(buildlistener);
         this. = releaseAction;
     }
 
     public void prepare() throws IOExceptionInterruptedException {
          = new PerforceManager();
         .prepare();
     }
 
     @Override
     public void beforeReleaseVersionChange() throws IOException {
     }
 
         String labelChangeListId = ExtractorUtils.getVcsRevision(.getEnvironment());
         if () {
             log("Submitting release version changes");
             labelChangeListId =  + "";
         } else {
             safeRevertWorkingCopy();
              = .getDefaultChangeListId();
         }
 
         if (.isCreateVcsTag()) {
             log("Creating label: '" + .getTagUrl() + "' with change list id: " + labelChangeListId);
             .createTag(.getTagUrl(), .getTagComment(), labelChangeListId);
              = true;
         }
     }
 
     public void beforeDevelopmentVersionChange() throws IOExceptionInterruptedException {
     }
 
     @Override
     public void afterDevelopmentVersionChange(boolean modifiedthrows IOExceptionInterruptedException {
         super.afterDevelopmentVersionChange(modified);
         if (modified) {
             log("Submitting next development version changes");
         } else {
             safeRevertWorkingCopy();
              = .getDefaultChangeListId();
         }
     }
 
     @Override
     public void edit(FilePath filePaththrows IOExceptionInterruptedException {
         .edit(filePath);
     }
 
     public void buildCompleted() throws IOExceptionInterruptedException {
         if (!.getResult().isBetterOrEqualTo(.)) {
            safeRevertWorkingCopy();
            if () {
                safeDeleteLabel();
            }
        } else {
            log("Closing connection to perforce server");
            .closeConnection();
        }
    }
    private void safeRevertWorkingCopy() {
        log("Reverting local changes");
        try {
        } catch (Exception e) {
            .log(."Failed to revert: "e);
            log("Failed to revert: " + e.getLocalizedMessage());
        }
    }
    private void safeDeleteLabel() throws IOException {
        log("Deleting label '" + .getTagUrl() + "'");
        try {
            .deleteLabel(.getTagUrl());
        } catch (Exception e) {
            .log(."Failed to delete label: "e);
            log("Failed to delete label: " + e.getLocalizedMessage());
        }
    }
    public String getRemoteUrlForPom() {
        return null;
    }
New to GrepCode? Check out our FAQ X