src/main/java/org/jenkinsci/plugins/openshift/GitClient.java
/**
	 * Deploy the deployment units through Git
	 * 
	 * @param deployments list of packages to be deployed
	 * @param workingCopyDir where git repo will be cloned 
	 * @param gitDeploymentDir the relative path in the working copy where the deployment packages should be copied
	 * @param commitMsg git commit message
	 * 
	 * @throws IOException
	 * @throws GitAPIException 
	 * @throws TransportException 
	 * @throws InvalidRemoteException 
	 */
Deploy the deployment units through Git

@param deployments list of packages to be deployed
@param workingCopyDir where git repo will be cloned
@param gitDeploymentDir the relative path in the working copy where the deployment packages should be copied
@param commitMsg git commit message


Deploy the deployment units through Git @param deployments list of packages to be deployed @param workingCopyDir where git repo will be cloned @param gitDeploymentDir the relative path in the working copy where the deployment packages should be copied @param commitMsg git commit message
public void deploy(List<String> deployments, File workingCopyDir, String relativeDeployDir, String commitMsg) 
			throws IOException, GitAPIException {
		log.info("Cloning '" + app.getName() + "' [" + app.getGitUrl() + "] to " + workingCopyDir);
		SshSessionFactory.setInstance(new JschConfigSessionFactory() {
			@Override
			protected void configure(Host hc, Session session) {
				session.setConfig("StrictHostKeyChecking", "no");
			}
		});
		Git git = Git.cloneRepository().setURI(app.getGitUrl()).setDirectory(workingCopyDir).call();
		File[] removeList = workingCopyDir.listFiles();
		for (File fileToRemove : removeList) {
			if (!fileToRemove.getName().equals(".git") && !fileToRemove.getName().equals(".openshift")) {
				log.info("Deleting '" + fileToRemove.getName() + "'");
				forceDelete(fileToRemove);
			}
		}
		File dest = new File(workingCopyDir.getAbsoluteFile() + relativeDeployDir);
		copyDeploymentPackages(deployments, dest);
		git.add().addFilepattern("webapps").call();
		git.add().addFilepattern("deployments").call();
		log.info("Commiting repo");
		git.commit().setAll(true).setMessage(commitMsg).call();
		log.info("Pushing to upstream");
		PushCommand pushCommand = git.push();
		pushCommand.setProgressMonitor(new TextProgressMonitor(new OutputStreamWriter(System.out)));
		pushCommand.call();
	}
public void deploy ( List < String > deployments , File workingCopyDir , String relativeDeployDir , String commitMsg ) throws IOException , GitAPIException { log . info ( "Cloning '" + app . getName ( ) + "' [" + app . getGitUrl ( ) + "] to " + workingCopyDir ) ; SshSessionFactory . setInstance ( new JschConfigSessionFactory ( ) { @ Override protected void configure ( Host hc , Session session ) { session . setConfig ( "StrictHostKeyChecking" , "no" ) ; } } ) ; Git git = Git . cloneRepository ( ) . setURI ( app . getGitUrl ( ) ) . setDirectory ( workingCopyDir ) . call ( ) ; File [ ] removeList = workingCopyDir . listFiles ( ) ; for ( File fileToRemove : removeList ) { if ( ! fileToRemove . getName ( ) . equals ( ".git" ) && ! fileToRemove . getName ( ) . equals ( ".openshift" ) ) { log . info ( "Deleting '" + fileToRemove . getName ( ) + "'" ) ; forceDelete ( fileToRemove ) ; } } File dest = new File ( workingCopyDir . getAbsoluteFile ( ) + relativeDeployDir ) ; copyDeploymentPackages ( deployments , dest ) ; git . add ( ) . addFilepattern ( "webapps" ) . call ( ) ; git . add ( ) . addFilepattern ( "deployments" ) . call ( ) ; log . info ( "Commiting repo" ) ; git . commit ( ) . setAll ( true ) . setMessage ( commitMsg ) . call ( ) ; log . info ( "Pushing to upstream" ) ; PushCommand pushCommand = git . push ( ) ; pushCommand . setProgressMonitor ( new TextProgressMonitor ( new OutputStreamWriter ( System . out ) ) ) ; pushCommand . call ( ) ; }
Deploy the deployment units through Git
Deploy the deployment units through Git
// clone repo // clean git repo // copy deployment // add directories // commit changes