@Override @Transactional public Application saveGitPush(Application application, String login) throws ServiceException, CheckException { logger.info("parameters - application : " + application.toString()); deploymentService.create(application, Type.GITPUSH); return application; }
@Override @Transactional public Application deploy(File file, Application application) throws ServiceException, CheckException { int code = -1; Map<String, String> configShell = new HashMap<>(); try { // get app with all its components for (Server server : application.getServers()) { // loading server ssh informations String rootPassword = server.getApplication().getUser().getPassword(); configShell.put("port", server.getSshPort()); configShell.put("dockerManagerAddress", application.getManagerIp()); configShell.put("password", rootPassword); String destFile = "/cloudunit/tmp/"; // send the file on container shellUtils.sendFile( file, rootPassword, server.getSshPort(), application.getManagerIp(), destFile); // call deployment script code = shellUtils.executeShell( "bash /cloudunit/scripts/deploy.sh " + file.getName() + " " + application.getUser().getLogin(), configShell); } // if all is ok, create a new deployment tag and set app to starting if (code == 0) { deploymentService.create(application, Type.WAR); } else { throw new CheckException("No way to deploy application " + file + ", " + application); } } catch (Exception e) { throw new ServiceException(e.getLocalizedMessage(), e); } return application; }