public string Process()
        {
            if (!Directory.Exists(_processingLocation))
            {
                Directory.CreateDirectory(_processingLocation);
            }

            _log.Debug("Starting to process Command Line task");

            String[] commandList = _taskScript.Content.Split(new String[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

            return(CommandWindowHelper.ProcessCommand(_processingLocation, _nodeLocation, _commandLineMinuteTimeout, commandList));
        }
Example #2
0
        public string Process()
        {
            _log.Debug("Starting to process node task");

            String nodeFileLocation = WriteNodeFile();

            _log.Debug("Node file created at " + nodeFileLocation);

            if (!String.IsNullOrEmpty(nodeFileLocation))
            {
                return(CommandWindowHelper.ProcessCommand(_processingLocation, _nodeLocation, _nodeMinuteTimeout, "node " + nodeFileLocation));
            }
            else
            {
                return(String.Empty);
            }
        }
        public string Process()
        {
            _log.Debug("Starting to process PhantomJS task");

            String phantomJSFileLocation = WritePhantomJSFile();

            _log.Debug("Grunt file created at " + phantomJSFileLocation);

            if (!String.IsNullOrEmpty(phantomJSFileLocation))
            {
                return(CommandWindowHelper.ProcessCommand(_processingLocation, _gruntMinuteTimeout, "\"" + _phantomJSLocation.TrimEnd(new char[] { '\\' }) + "\\phantomjs.exe\" " + "\"" + phantomJSFileLocation + "\""));
            }
            else
            {
                return(String.Empty);
            }
        }
Example #4
0
        public string Process()
        {
            _log.Debug("Starting to process grunt task");

            String gruntFileLocation = WriteGruntFile();

            _log.Debug("Grunt file created at " + gruntFileLocation);

            CommandWindowHelper.ProcessCommand(_processingLocation, _nodeLocation, _gruntMinuteTimeout, "npm install -g grunt-cli");

            if (!String.IsNullOrEmpty(gruntFileLocation))
            {
                return(CommandWindowHelper.ProcessCommand(_processingLocation, _nodeLocation, _gruntMinuteTimeout, "grunt"));
            }
            else
            {
                return(String.Empty);
            }
        }
        public String Process()
        {
            _log.Debug("Starting to process Git task");

            Dictionary <String, String> scriptOptions = JsonConvert.DeserializeObject <Dictionary <String, String> >(_taskScript.Content);

            String location = String.Empty;

            if (scriptOptions.ContainsKey("Location"))
            {
                location = scriptOptions["Location"];

                _log.Debug("Processing location for Git task set to " + location);
            }

            String username = String.Empty;

            if (scriptOptions.ContainsKey("Username"))
            {
                username = scriptOptions["Username"];

                _log.Debug("Processing username for Git task set to " + username);
            }

            String password = String.Empty;

            if (scriptOptions.ContainsKey("Password"))
            {
                password = scriptOptions["Password"];

                _log.Debug("Processing password for Git task set");
            }

            if (!String.IsNullOrEmpty(location))
            {
                String gitURL = GetGitURL(location, username, password);

                _log.Debug("Git url supplied " + gitURL);

                if (!Directory.Exists(_processingLocation))
                {
                    Directory.CreateDirectory(_processingLocation);
                }

                String[] processingLocationParts = _processingLocation.TrimEnd(new char[] { '\\' }).Split(new char[] { '\\' });

                String formattedProcessingLocation = _processingLocation.TrimEnd(new char[] { '\\' }).Replace("\\" + processingLocationParts.Last(), String.Empty);

                if (!String.IsNullOrEmpty(gitURL))
                {
                    return(CommandWindowHelper.ProcessCommand(formattedProcessingLocation, _gitMinuteTimeout, "git clone " + gitURL + " " + processingLocationParts.Last()));
                }
                else
                {
                    return(String.Empty);
                }
            }
            else
            {
                _log.Info("Processing location for Git task not found for task " + _taskScript.ID);

                return(String.Empty);
            }
        }
        private void processTaskScript(String scriptProcessingLocation, Task task, TaskScript taskScript)
        {
            _log.Debug("Determining task type");

            IProcessor processor = null;

            switch (taskScript.Type)
            {
            case ScriptType.Git:
                processor = new GitProcessor(scriptProcessingLocation, taskScript);
                break;

            case ScriptType.CommandLine:
                processor = new CommandLineProcessor(scriptProcessingLocation, _nodeLocation, taskScript);
                break;

            case ScriptType.Node:
                processor = new NodeProcessor(scriptProcessingLocation, _nodeLocation, taskScript);
                break;

            case ScriptType.Grunt:
                processor = new GruntProcessor(scriptProcessingLocation, _nodeLocation, taskScript);
                break;

            case ScriptType.PhantomJS:
                processor = new PhantomJSProcessor(scriptProcessingLocation, _phantomJSLocation, taskScript);
                break;
            }

            String processResults = String.Empty;

            if (processor != null)
            {
                _log.Debug("Starting to process task");

                if (!Directory.Exists(scriptProcessingLocation))
                {
                    Directory.CreateDirectory(scriptProcessingLocation);
                }

                _log.Debug("Checking for any required node packages");

                foreach (String requiredPackage in processor.GetRequiredPackages())
                {
                    PackageCache packageCache = _packageCacheDataAccess.Get(task.Project.ID, requiredPackage);

                    _log.Debug("Package required: " + requiredPackage);

                    String packageCacheLocation  = _packageCacheLocation.TrimEnd(new char[] { '\\' }) + "\\" + task.Project.ID + "\\" + requiredPackage;
                    String targetPackageLocation = scriptProcessingLocation.TrimEnd(new char[] { '\\' }) + "\\node_modules\\" + requiredPackage;

                    _log.Debug("Package cache location: " + packageCacheLocation);
                    _log.Debug("target package location: " + targetPackageLocation);

                    if ((packageCache == null) ||
                        ((packageCache != null) && (!packageCache.Store)) ||
                        ((packageCache != null) && (packageCache.Store) && (!Directory.Exists(packageCacheLocation))))
                    {
                        _log.Debug("Cached package does not exist so importing");

                        processResults += CommandWindowHelper.ProcessCommand(scriptProcessingLocation, _nodeLocation, 5, "npm install " + requiredPackage) + Environment.NewLine;
                    }
                    else
                    {
                        _log.Debug("Cached package exists so attempting to pull into place");

                        Boolean packageImportSuccessful = IOHelper.CopyDirectory(packageCacheLocation, targetPackageLocation);

                        _log.Debug("Check if the cach package copy was successfull");

                        if (!packageImportSuccessful)
                        {
                            _log.Debug("Cache package copy failed so pulling " + requiredPackage + " from npm");

                            processResults += CommandWindowHelper.ProcessCommand(scriptProcessingLocation, _nodeLocation, 5, "npm install " + requiredPackage) + Environment.NewLine;
                        }
                    }

                    _log.Debug("Checking that we now have the target package");

                    if (Directory.Exists(targetPackageLocation))
                    {
                        _log.Debug("We do have the package so copy it into cache");

                        Boolean copySuccessful = true;

                        if ((packageCache == null) ||
                            ((packageCache != null) && (packageCache.Store) && (!Directory.Exists(packageCacheLocation))))
                        {
                            copySuccessful = IOHelper.CopyDirectory(targetPackageLocation, packageCacheLocation);
                        }

                        if ((packageCache == null) && (copySuccessful))
                        {
                            packageCache            = new PackageCache();
                            packageCache.ExternalId = System.Guid.NewGuid().ToString();
                            packageCache.Name       = requiredPackage;
                            packageCache.Version    = IOHelper.GetPackageVersion(targetPackageLocation);
                            packageCache.Store      = true;
                            packageCache.Project    = task.Project;

                            packageCache = _packageCacheDataAccess.Insert(packageCache);
                        }
                    }
                }

                processResults += processor.Process();
            }

            _taskScriptDataAccess.UpdateTaskScriptLog(taskScript.ID, processResults);
        }