public override Activity ToSdkObject()
        {
            var activity = new ExecutionActivity(this.Name);

            activity.LinkedServiceName = this.LinkedServiceName;
            activity.Policy            = this.Policy;
            SetProperties(activity);
            return(activity);
        }
Example #2
0
 /// <summary>
 /// Handle exception
 /// </summary>
 /// <param name="appEx">application exception</param>
 /// <param name="activity">activity in context</param>
 protected void HandleException(Exception appEx, ExecutionActivity activity)
 {
     _lastException = appEx;
     quitExecuting  = true;
     this.Result    = new ExecutionResult()
     {
         IsSuccess = false, Message = appEx.Message
     };
 }
Example #3
0
 private void ValidateBasics(ExecutionActivity step)
 {
     if (step == null)
     {
         throw new ApplicationException("Pipeline Validation Failure: Activity is null.");
     }
     logger.InfoFormat("Validating step: {0}", step.Name);
     if ((step.Host == null) || string.IsNullOrWhiteSpace(step.Host.HostName))
     {
         throw new ApplicationException("Pipeline Validation Failure: Host details are unavailable.");
     }
 }
        public AbstractExecutor GetExecutor(ExecutionActivity executionActivity)
        {
            var executionType = executionActivity.Operation;

            switch (executionType)
            {
            case ExecutionType.StartService:
                return(new StartServiceExecutor(executionActivity, new PowershellManager()));

            case ExecutionType.StopService:
                return(new StopServiceExecutor(executionActivity, new PowershellManager()));

            case ExecutionType.AddSslCertificate:
                return(new AddSslCertificateExecutor(executionActivity, new PowershellManager()));

            case ExecutionType.CopyFiles:
                return(new CopyFilesExecutor(executionActivity, new PowershellManager()));

            case ExecutionType.CreateIISWebsite:
                return(new CreateIISWebsiteExecutor(executionActivity, new PowershellManager()));

            case ExecutionType.DeleteFiles:
                return(new DeleteFilesExecutor(executionActivity, new PowershellManager()));

            case ExecutionType.MoveFiles:
                return(new MoveFilesExecutor(executionActivity, new PowershellManager()));

            case ExecutionType.StartIISWebServer:
                return(new StartIISWebServerExecutor(executionActivity, new PowershellManager()));

            case ExecutionType.StartIISWebsite:
                return(new StartIISWebsiteExecutor(executionActivity, new PowershellManager()));

            case ExecutionType.StopIISWebServer:
                return(new StopIISWebServerExecutor(executionActivity, new PowershellManager()));

            case ExecutionType.StopIISWebsite:
                return(new StopIISWebsiteExecutor(executionActivity, new PowershellManager()));

            case ExecutionType.GitClone:
                return(new GitCloneExecutor(executionActivity, new PowershellManager()));

            case ExecutionType.SvnCheckout:
                return(new SvnCheckoutExecutor(executionActivity, new PowershellManager()));

            case ExecutionType.MsBuild:
                return(new MsBuildExecutor(executionActivity, new PowershellManager()));

            default:
                throw new NotImplementedException("No executors were found for this type.");
            }
        }
        public void ExecutionPipeline_Add_ThrowsException_WhenActivityFailsValidation()
        {
            //// Arrange
            var executorProviderMock          = new Mock <IExecutorProvider>();
            ExecutionPipeline pipeline        = new ExecutionPipeline(executorProviderMock.Object);
            ExecutionActivity invalidActivity = GetInvalidActivity();

            //// Act
            pipeline.Add(invalidActivity);

            //// Assert
            Assert.Fail();
        }
        public void ExecutionPipeline_Add_AddsStep_WhenValid()
        {
            //// Arrange
            var executorProviderMock        = new Mock <IExecutorProvider>();
            ExecutionPipeline pipeline      = new ExecutionPipeline(executorProviderMock.Object);
            ExecutionActivity validActivity = GetValidActivity();

            //// Act
            pipeline.Add(validActivity);

            //// Assert
            Assert.IsTrue(pipeline.Steps.Count == 1);
            Assert.IsTrue(object.ReferenceEquals(pipeline.Steps.First(), validActivity));
        }
Example #7
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="activity"></param>
        /// <param name="shellManager"></param>
        public AbstractExecutor(ExecutionActivity activity, IShellManager shellManager)
        {
            this.Activity = activity;
            _shellManager = shellManager;

            //// Get script for the activity through activity script provider
            this.ActivityScriptMap = ActivityScriptProvider.GetActivityScriptMap(activity.Operation);
            if (!string.IsNullOrWhiteSpace(this.ActivityScriptMap.ExecutionScriptFile))
            {
                var executionScript = File.ReadAllText(Path.Combine(Constants.PowershellScripts.ScriptsFolder, this.ActivityScriptMap.ExecutionScriptFile));
                this.ActivityScriptMap.ExecutionScript = executionScript;
            }
            if (!string.IsNullOrWhiteSpace(this.ActivityScriptMap.VerificationScriptFile))
            {
                var verificationScript = File.ReadAllText(Path.Combine(Constants.PowershellScripts.ScriptsFolder, this.ActivityScriptMap.VerificationScriptFile));
                this.ActivityScriptMap.VerificationScript = verificationScript;
            }
        }
Example #8
0
        /// <summary>
        /// Adding a step to pipeline
        /// </summary>
        /// <param name="step"></param>
        public void Add(ExecutionActivity step)
        {
            ValidateBasics(step);
            bool isValid = step.IsValid();

            if (isValid)
            {
                this.Steps.Add(step);
                if (StepAdded != null)
                {
                    StepAdded(this, new ActivityEventArgs()
                    {
                        Activity = step
                    });
                }
            }
            else
            {
                throw new ApplicationException("Pipeline Validation Failure: Activity Validation Failed.");
            }
        }
        public void ExecutionPipeline_Add_RaisesEvent_AfterAddingStep_AndPassesActivityInEventArgs()
        {
            //// Arrange
            var executorProviderMock        = new Mock <IExecutorProvider>();
            ExecutionPipeline pipeline      = new ExecutionPipeline(executorProviderMock.Object);
            ExecutionActivity validActivity = GetValidActivity();
            bool      eventRaised           = false;
            EventArgs addedEventArgs        = null;

            pipeline.StepAdded += (sender, e) =>
            {
                eventRaised    = true;
                addedEventArgs = e;
            };

            //// Act
            pipeline.Add(validActivity);

            //// Assert
            Assert.IsTrue(eventRaised);
            Assert.IsTrue(object.ReferenceEquals(((ActivityEventArgs)addedEventArgs).Activity, validActivity));
        }
 public GitCloneExecutor(ExecutionActivity activity, IShellManager shellManager)
     : base(activity, shellManager)
 {
     logger = LogManager.GetLogger(typeof(GitCloneExecutor));
 }
 public AddSslCertificateExecutor(ExecutionActivity activity, IShellManager shellManager)
     : base(activity, shellManager)
 {
     logger = LogManager.GetLogger(typeof(AddSslCertificateExecutor));
 }
 public CopyFilesExecutor(ExecutionActivity activity, IShellManager shellManager)
     : base(activity, shellManager)
 {
     logger = LogManager.GetLogger(typeof(CopyFilesExecutor));
 }
Example #13
0
 public StartIISWebsiteExecutor(ExecutionActivity activity, IShellManager shellManager)
     : base(activity, shellManager)
 {
     logger = LogManager.GetLogger(typeof(StartIISWebsiteExecutor));
 }
Example #14
0
 public SvnCheckoutExecutor(ExecutionActivity activity, IShellManager shellManager)
     : base(activity, shellManager)
 {
     logger = LogManager.GetLogger(typeof(SvnCheckoutExecutor));
 }
 public MsBuildExecutor(ExecutionActivity activity, IShellManager shellManager)
     : base(activity, shellManager)
 {
     logger = LogManager.GetLogger(typeof(MsBuildExecutor));
 }
 public StopServiceExecutor(ExecutionActivity activity, IShellManager shellManager)
     : base(activity, shellManager)
 {
     logger = LogManager.GetLogger(typeof(StopServiceExecutor));
 }
Example #17
0
 /// <summary>
 /// default constructor
 /// </summary>
 /// <param name="operation">operation string - as per ExecutionType enum.</param>
 /// <param name="activitySetting">setting - equivalent activity object</param>
 public ActivityConfigEntry(string operation, ExecutionActivity settings)
 {
     /// Do not change this assigning order - so the property validations happen in order.
     this.Operation = operation;
     this.Settings  = settings;
 }