当前位置: 首页>>代码示例>>C#>>正文


C# IExecutionContext.Debug方法代码示例

本文整理汇总了C#中IExecutionContext.Debug方法的典型用法代码示例。如果您正苦于以下问题:C# IExecutionContext.Debug方法的具体用法?C# IExecutionContext.Debug怎么用?C# IExecutionContext.Debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IExecutionContext的用法示例。


在下文中一共展示了IExecutionContext.Debug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EnableCodeCoverage

        public void EnableCodeCoverage(IExecutionContext context, CodeCoverageEnablerInputs ccInputs)
        {
            Trace.Entering();
            _executionContext = context;

            ccInputs.VerifyInputsForJacocoMaven();

            context.Debug(StringUtil.Format(CodeCoverageConstants.EnablingEditingTemplate, "jacoco", "maven", ccInputs.BuildFile));

            // see jacoco maven documentation for more details. http://www.eclemma.org/jacoco/trunk/doc/maven.html
            XElement pomXml;
            try
            {
                pomXml = XElement.Load(ccInputs.BuildFile);
            }
            catch (XmlException e)
            {
                _executionContext.Warning(StringUtil.Loc("InvalidBuildXml", ccInputs.BuildFile, e.Message));
                throw;
            }

            XNamespace xNameSpace = pomXml.Attribute("xmlns").Value;

            if (pomXml.Element(xNameSpace + "modules") != null)
            {
                // aa multi module project 
                _isMultiModule = true;
                context.Debug(CodeCoverageConstants.MavenMultiModule);
            }

            // Add a build element if doesnot exist.
            var build = pomXml.Element(xNameSpace + "build");
            if (build == null)
            {
                pomXml.Add(new XElement("build"));
                build = pomXml.Element("build");
            }

            // Set jacoco plugins to enable code coverage.
            SetPlugins(build, ccInputs, xNameSpace);

            foreach (var e in build.DescendantsAndSelf().Where(e => string.IsNullOrEmpty(e.Name.Namespace.NamespaceName)))
            {
                e.Name = xNameSpace + e.Name.LocalName;
            }

            using (FileStream stream = new FileStream(ccInputs.BuildFile, FileMode.Create))
            {
                pomXml.Save(stream);
            }

            if (_isMultiModule)
            {
                CreateReportPomForMultiModule(ccInputs.ReportBuildFile, xNameSpace, pomXml, ccInputs);
            }

            context.Output(StringUtil.Loc("CodeCoverageEnabled", "jacoco", "maven"));
        }
开发者ID:codedebug,项目名称:vsts-agent,代码行数:58,代码来源:CodeCoverageEnablerForJacocoMaven.cs

示例2: LoadGitExecutionInfo

        public async Task LoadGitExecutionInfo(IExecutionContext context)
        {
#if OS_WINDOWS
            _gitPath = Path.Combine(IOUtil.GetExternalsPath(), "git", "cmd", $"git{IOUtil.ExeExtension}");
#else
            _gitPath = Path.Combine(IOUtil.GetExternalsPath(), "git", "bin", $"git{IOUtil.ExeExtension}");
#endif
            if (string.IsNullOrEmpty(_gitPath) || !File.Exists(_gitPath))
            {
                throw new Exception(StringUtil.Loc("GitNotFound"));
            }

            context.Debug($"Find git from agent's external directory: {_gitPath}.");
            context.Debug($"Prepend git directory '{Path.GetDirectoryName(_gitPath)}' to PATH env.");

#if OS_WINDOWS
            string path = Environment.GetEnvironmentVariable("Path");
#else
            string path = Environment.GetEnvironmentVariable("PATH");            
#endif

            if (string.IsNullOrEmpty(path))
            {
                path = Path.GetDirectoryName(_gitPath);
            }
            else
            {
                path = Path.GetDirectoryName(_gitPath) + Path.PathSeparator + path;
            }

#if OS_WINDOWS
            Environment.SetEnvironmentVariable("Path", path);
#else
            Environment.SetEnvironmentVariable("PATH", path);            
#endif

            _version = await GitVersion(context);
            context.Debug($"Detect git version: {_version.ToString()}.");

            _gitHttpUserAgentEnv = $"git/{_version.ToString()} (vsts-agent-git/{Constants.Agent.Version})";
            context.Debug($"Set git useragent to: {_gitHttpUserAgentEnv}.");

#if !OS_WINDOWS
            string _gitExecPathEnv = Path.Combine(IOUtil.GetExternalsPath(), "git", "libexec", "git-core");
            context.Debug($"Set git execpath to: {_gitExecPathEnv}");
            string _gitTemplatePathEnv = Path.Combine(IOUtil.GetExternalsPath(), "git", "share", "git-core", "templates");
            context.Debug($"Set git templateDir to: {_gitTemplatePathEnv}");
            
            Environment.SetEnvironmentVariable("GIT_EXEC_PATH", _gitExecPathEnv);
            Environment.SetEnvironmentVariable("GIT_TEMPLATE_DIR", _gitTemplatePathEnv);
#endif
        }
开发者ID:codedebug,项目名称:vsts-agent,代码行数:52,代码来源:GitCommandManager.cs

示例3: TryProcessCommand

        public bool TryProcessCommand(IExecutionContext context, string input)
        {
            if (string.IsNullOrEmpty(input))
            {
                return false;
            }

            // TryParse input to Command
            Command command;
            if (!Command.TryParse(input, out command))
            {
                // if parse fail but input contains ##vso, print warning with DOC link
                if (input.IndexOf("##vso") >= 0)
                {
                    context.Warning($"'{input}' contains logging command keyword '##vso'. TODO: aka link to command DOC.");
                }

                return false;
            }

            context.Debug($"Try processing logging command: ##vso[{command.Area}.{command.Event}]");
            IWorkerCommandExtension extension;
            if (_commandExtensions.TryGetValue(command.Area, out extension))
            {
                // process logging command in serialize oreder.
                lock (_commandSerializeLock)
                {
                    try
                    {
                        extension.ProcessCommand(context, command);
                        context.Debug($"Processed logging command: {input}");
                    }
                    catch (Exception ex)
                    {
                        context.Error(ex);
                        context.Error($"Unable to process command {input} successfully.");
                        context.CommandResult = TaskResult.Failed;
                    }
                }
            }
            else
            {
                context.Warning(StringUtil.Loc("CommandNotFound", command.Area));
            }

            return true;
        }
开发者ID:codedebug,项目名称:vsts-agent,代码行数:47,代码来源:WorkerCommandManager.cs

示例4: GetSourceAsync

        public async Task GetSourceAsync(IExecutionContext executionContext, ServiceEndpoint endpoint, CancellationToken cancellationToken)
        {
            Trace.Verbose("Entering SvnSourceProvider.GetSourceAsync");

            // Validate args.
            ArgUtil.NotNull(executionContext, nameof(executionContext));
            ArgUtil.NotNull(endpoint, nameof(endpoint));

            ISvnCommandManager svn = HostContext.CreateService<ISvnCommandManager>();
            svn.Init(executionContext, endpoint, cancellationToken);

            // Determine the sources directory.
            string sourcesDirectory = executionContext.Variables.Build_SourcesDirectory;
            executionContext.Debug($"sourcesDirectory={sourcesDirectory}");
            ArgUtil.NotNullOrEmpty(sourcesDirectory, nameof(sourcesDirectory));

            string sourceBranch = executionContext.Variables.Build_SourceBranch;
            executionContext.Debug($"sourceBranch={sourceBranch}");

            string revision = executionContext.Variables.Build_SourceVersion;
            if (string.IsNullOrWhiteSpace(revision))
            {
                revision = "HEAD";
            }
            executionContext.Debug($"revision={revision}");

            bool clean = endpoint.Data.ContainsKey(WellKnownEndpointData.Clean) &&
                StringUtil.ConvertToBoolean(endpoint.Data[WellKnownEndpointData.Clean], defaultValue: false);
            executionContext.Debug($"clean={clean}");

            // Get the definition mappings.
            List<SvnMappingDetails> allMappings = JsonConvert.DeserializeObject<SvnWorkspace>(endpoint.Data[WellKnownEndpointData.SvnWorkspaceMapping]).Mappings;

            if (executionContext.Variables.System_Debug.HasValue && executionContext.Variables.System_Debug.Value)
            {
                allMappings.ForEach(m => executionContext.Debug($"ServerPath: {m.ServerPath}, LocalPath: {m.LocalPath}, Depth: {m.Depth}, Revision: {m.Revision}, IgnoreExternals: {m.IgnoreExternals}"));
            }

            Dictionary<string, SvnMappingDetails> normalizedMappings = svn.NormalizeMappings(allMappings);
            if (executionContext.Variables.System_Debug.HasValue && executionContext.Variables.System_Debug.Value)
            {
                executionContext.Debug($"Normalized mappings count: {normalizedMappings.Count}");
                normalizedMappings.ToList().ForEach(p => executionContext.Debug($"    [{p.Key}] ServerPath: {p.Value.ServerPath}, LocalPath: {p.Value.LocalPath}, Depth: {p.Value.Depth}, Revision: {p.Value.Revision}, IgnoreExternals: {p.Value.IgnoreExternals}"));
            }

            string normalizedBranch = svn.NormalizeRelativePath(sourceBranch, '/', '\\');

            executionContext.Output(StringUtil.Loc("SvnSyncingRepo", endpoint.Name));

            string effectiveRevision = await svn.UpdateWorkspace(
                sourcesDirectory,
                normalizedMappings,
                clean,
                normalizedBranch,
                revision);

            executionContext.Output(StringUtil.Loc("SvnBranchCheckedOut", normalizedBranch, endpoint.Name, effectiveRevision));
            Trace.Verbose("Leaving SvnSourceProvider.GetSourceAsync");
        }
开发者ID:codedebug,项目名称:vsts-agent,代码行数:59,代码来源:SvnSourceProvider.cs

示例5: EnableCodeCoverage

        public void EnableCodeCoverage(IExecutionContext context, CodeCoverageEnablerInputs ccInputs)
        {
            Trace.Entering();

            ccInputs.VerifyInputsForCoberturaGradle();

            context.Debug(StringUtil.Format(CodeCoverageConstants.EnablingEditingTemplate, "cobertura", "gradle", ccInputs.BuildFile));
            var buildScript = new FileInfo(ccInputs.BuildFile);

            if (buildScript.Length == 0)
            {
                throw new InvalidOperationException(StringUtil.Loc("CodeCoverageBuildFileIsEmpty", ccInputs.BuildFile));
            }

            CodeCoverageUtilities.PrependDataToFile(ccInputs.BuildFile, GetCoberturaPluginDefination());
            File.AppendAllText(ccInputs.BuildFile, GetGradleCoberturaReport(ccInputs));
            context.Output(StringUtil.Loc("CodeCoverageEnabled", "cobertura", "gradle"));
        }
开发者ID:codedebug,项目名称:vsts-agent,代码行数:18,代码来源:CodeCoverageEnablerForCoberturaGradle.cs

示例6: CreateDirectory

        public void CreateDirectory(IExecutionContext executionContext, string description, string path, bool deleteExisting)
        {
            // Delete.
            if (deleteExisting)
            {
                executionContext.Debug($"Delete existing {description}: '{path}'");
                DeleteDirectory(executionContext, description, path);
            }

            // Create.
            if (!Directory.Exists(path))
            {
                executionContext.Debug($"Creating {description}: '{path}'");
                Trace.Info($"Creating {description}.");
                Directory.CreateDirectory(path);
            }
        }
开发者ID:codedebug,项目名称:vsts-agent,代码行数:17,代码来源:BuildDirectoryManager.cs

示例7: RemoveCachedCredential

        private async Task RemoveCachedCredential(IExecutionContext context, string repositoryPath, Uri repositoryUrl, string remoteName)
        {
            //remove credential from fetch url
            context.Debug("Remove injected credential from git remote fetch url.");
            int exitCode_seturl = await _gitCommandManager.GitRemoteSetUrl(context, repositoryPath, remoteName, repositoryUrl.AbsoluteUri);

            context.Debug("Remove injected credential from git remote push url.");
            int exitCode_setpushurl = await _gitCommandManager.GitRemoteSetPushUrl(context, repositoryPath, remoteName, repositoryUrl.AbsoluteUri);

            if (exitCode_seturl != 0 || exitCode_setpushurl != 0)
            {
                // if unable to use git.exe set fetch url back, modify git config file on disk. make sure we don't left credential.
                context.Warning("Unable to use git.exe remove injected credential from git remote fetch url, modify git config file on disk to remove injected credential.");
                string gitConfig = Path.Combine(repositoryPath, ".git/config");
                if (File.Exists(gitConfig))
                {
                    string gitConfigContent = File.ReadAllText(Path.Combine(repositoryPath, ".git", "config"));
                    Uri urlWithCred;
                    if (_credentialUrlCache.TryGetValue(repositoryUrl.AbsoluteUri, out urlWithCred))
                    {
                        gitConfigContent = gitConfigContent.Replace(urlWithCred.AbsoluteUri, repositoryUrl.AbsoluteUri);
                        File.WriteAllText(gitConfig, gitConfigContent);
                    }
                }
            }
        }
开发者ID:codedebug,项目名称:vsts-agent,代码行数:26,代码来源:GitSourceProvider.cs

示例8: GitSubmoduleInit

 // git submodule init
 public async Task<int> GitSubmoduleInit(IExecutionContext context, string repositoryPath)
 {
     context.Debug("Initialize the git submodules.");
     return await ExecuteGitCommandAsync(context, repositoryPath, "submodule", "init");
 }
开发者ID:codedebug,项目名称:vsts-agent,代码行数:6,代码来源:GitCommandManager.cs

示例9: ProcessArtifactAssociateCommand

        private void ProcessArtifactAssociateCommand(IExecutionContext context, Dictionary<string, string> eventProperties, string data)
        {
            ArgUtil.NotNull(context, nameof(context));
            ArgUtil.NotNull(context.Endpoints, nameof(context.Endpoints));

            ServiceEndpoint systemConnection = context.Endpoints.FirstOrDefault(e => string.Equals(e.Name, ServiceEndpoints.SystemVssConnection, StringComparison.OrdinalIgnoreCase));
            ArgUtil.NotNull(systemConnection, nameof(systemConnection));
            ArgUtil.NotNull(systemConnection.Url, nameof(systemConnection.Url));

            Uri projectUrl = systemConnection.Url;
            VssCredentials projectCredential = ApiUtil.GetVssCredential(systemConnection);

            Guid projectId = context.Variables.System_TeamProjectId ?? Guid.Empty;
            ArgUtil.NotEmpty(projectId, nameof(projectId));

            int? buildId = context.Variables.Build_BuildId;
            ArgUtil.NotNull(buildId, nameof(buildId));

            string artifactName;
            if (!eventProperties.TryGetValue(ArtifactAssociateEventProperties.ArtifactName, out artifactName) ||
                string.IsNullOrEmpty(artifactName))
            {
                throw new Exception(StringUtil.Loc("ArtifactNameRequired"));
            }

            string artifactLocation = data;
            if (string.IsNullOrEmpty(artifactLocation))
            {
                throw new Exception(StringUtil.Loc("ArtifactLocationRequired"));
            }

            string artifactType;
            if (!eventProperties.TryGetValue(ArtifactAssociateEventProperties.ArtifactType, out artifactType))
            {
                artifactType = InferArtifactResourceType(context, artifactLocation);
            }

            if (string.IsNullOrEmpty(artifactType))
            {
                throw new Exception(StringUtil.Loc("ArtifactTypeRequired"));
            }

            var propertyDictionary = ExtractArtifactProperties(eventProperties);

            string artifactData = "";
            if (IsContainerPath(artifactLocation) ||
                IsValidServerPath(artifactLocation))
            {
                //if artifactlocation is a file container path or a tfvc server path
                artifactData = artifactLocation;
            }
            else if (IsUncSharePath(context, artifactLocation))
            {
                //if artifactlocation is a UNC share path
                artifactData = new Uri(artifactLocation).LocalPath;
            }
            else
            {
                throw new Exception(StringUtil.Loc("ArtifactLocationNotSupport", artifactLocation));
            }

            // queue async command task to associate artifact.
            context.Debug($"Associate artifact: {artifactName} with build: {buildId.Value} at backend.");
            var commandContext = HostContext.CreateService<IAsyncCommandContext>();
            commandContext.InitializeCommandContext(context, StringUtil.Loc("AssociateArtifact"));
            commandContext.Task = AssociateArtifactAsync(commandContext,
                                                         projectUrl,
                                                         projectCredential,
                                                         projectId,
                                                         buildId.Value,
                                                         artifactName,
                                                         artifactType,
                                                         artifactData,
                                                         propertyDictionary,
                                                         context.CancellationToken);
            context.AsyncCommands.Add(commandContext);
        }
开发者ID:codedebug,项目名称:vsts-agent,代码行数:77,代码来源:ArtifactCommandExtension.cs

示例10: ProcessArtifactUploadCommand

        private void ProcessArtifactUploadCommand(IExecutionContext context, Dictionary<string, string> eventProperties, string data)
        {
            ArgUtil.NotNull(context, nameof(context));
            ArgUtil.NotNull(context.Endpoints, nameof(context.Endpoints));

            ServiceEndpoint systemConnection = context.Endpoints.FirstOrDefault(e => string.Equals(e.Name, ServiceEndpoints.SystemVssConnection, StringComparison.OrdinalIgnoreCase));
            ArgUtil.NotNull(systemConnection, nameof(systemConnection));
            ArgUtil.NotNull(systemConnection.Url, nameof(systemConnection.Url));

            Uri projectUrl = systemConnection.Url;
            VssCredentials projectCredential = ApiUtil.GetVssCredential(systemConnection);

            Guid projectId = context.Variables.System_TeamProjectId ?? Guid.Empty;
            ArgUtil.NotEmpty(projectId, nameof(projectId));

            int? buildId = context.Variables.Build_BuildId;
            ArgUtil.NotNull(buildId, nameof(buildId));

            long? containerId = context.Variables.Build_ContainerId;
            ArgUtil.NotNull(containerId, nameof(containerId));

            string artifactName;
            if (!eventProperties.TryGetValue(ArtifactAssociateEventProperties.ArtifactName, out artifactName) || 
                string.IsNullOrEmpty(artifactName))
            {
                throw new Exception(StringUtil.Loc("ArtifactNameRequired"));
            }

            string containerFolder;
            if (!eventProperties.TryGetValue(ArtifactUploadEventProperties.ContainerFolder, out containerFolder) || 
                string.IsNullOrEmpty(containerFolder))
            {
                containerFolder = artifactName;
            }

            var propertyDictionary = ExtractArtifactProperties(eventProperties);

            string localPath = data;
            if (string.IsNullOrEmpty(localPath))
            {
                throw new Exception(StringUtil.Loc("ArtifactLocationRequired"));
            }

            string fullPath = Path.GetFullPath(localPath);
            if (!File.Exists(fullPath) && !Directory.Exists(fullPath))
            {
                // if localPath is not a file or folder on disk
                throw new FileNotFoundException(StringUtil.Loc("PathNotExist", localPath));
            }
            else if (Directory.Exists(fullPath) && Directory.EnumerateFiles(fullPath, "*", SearchOption.AllDirectories).FirstOrDefault() == null)
            {
                // if localPath is a folder but the folder contains nothing
                context.Warning(StringUtil.Loc("DirectoryIsEmptyForArtifact", fullPath, artifactName));
                return;
            }

            // queue async command task to associate artifact.
            context.Debug($"Upload artifact: {fullPath} to server for build: {buildId.Value} at backend.");
            var commandContext = HostContext.CreateService<IAsyncCommandContext>();
            commandContext.InitializeCommandContext(context, StringUtil.Loc("UploadArtifact"));
            commandContext.Task = UploadArtifactAsync(commandContext,
                                                      projectUrl,
                                                      projectCredential,
                                                      projectId,
                                                      containerId.Value,
                                                      containerFolder,
                                                      buildId.Value,
                                                      artifactName,
                                                      propertyDictionary,
                                                      fullPath,
                                                      context.CancellationToken);
            context.AsyncCommands.Add(commandContext);
        }
开发者ID:codedebug,项目名称:vsts-agent,代码行数:73,代码来源:ArtifactCommandExtension.cs

示例11: EnableCodeCoverage

        public void EnableCodeCoverage(IExecutionContext context, CodeCoverageEnablerInputs ccInputs)
        {
            Trace.Entering();

            ccInputs.VerifyInputsForJacocoGradle();

            context.Debug(StringUtil.Format(CodeCoverageConstants.EnablingEditingTemplate, "jacoco", "gradle", ccInputs.BuildFile));

            var buildScript = new FileInfo(ccInputs.BuildFile);

            if (buildScript.Length == 0)
            {
                throw new InvalidOperationException(StringUtil.Loc("CodeCoverageBuildFileIsEmpty", ccInputs.BuildFile));
            }

            // see jacoco gradle documentation for more details. https://docs.gradle.org/current/userguide/jacoco_plugin.html

            var jacocoExclude = CodeCoverageUtilities.TrimToEmptyString(ccInputs.Exclude).Replace('.', '/');
            var jacocoInclude = CodeCoverageUtilities.TrimToEmptyString(ccInputs.Include).Replace('.', '/');
            var exclude = string.IsNullOrEmpty(jacocoExclude) ? string.Empty : string.Join(",", jacocoExclude.Split(':').Select(
                exclPackage => exclPackage.EndsWith("*") ? ("'" + exclPackage + "/**'") : ("'" + exclPackage + ".class'")));
            var include = string.IsNullOrEmpty(jacocoInclude) ? string.Empty : string.Join(",", jacocoInclude.Split(':').Select(
                inclPackage => inclPackage.EndsWith("*") ? ("'" + inclPackage + "/**'") : ("'" + inclPackage + ".class'")));

            var enableJacoco = string.Empty;

            if (ccInputs.IsMultiModule)
            {
                enableJacoco = @"
                    allprojects { apply plugin: 'jacoco' }

                    allprojects {
	                    repositories {
                            mavenCentral()
                        }
                    }

                    def jacocoExcludes = [" + CodeCoverageUtilities.TrimToEmptyString(exclude) + @"]
                    def jacocoIncludes = [" + CodeCoverageUtilities.TrimToEmptyString(include) + @"]

                    subprojects {
	
                        jacocoTestReport {
		                    doFirst {
			                    classDirectories = fileTree(dir: """ + ccInputs.ClassFilesDirectories + @""").exclude(jacocoExcludes).include(jacocoIncludes)
		                    }
		
		                    reports {
			                    html.enabled = true
			                    html.destination ""${buildDir}/jacocoHtml""
                                xml.enabled = true    
	                            xml.destination ""${buildDir}" + "/" + _summaryFile + @"""
                            }
                        }
	
	                    test {
		                    jacoco {
			                    append = true
			                    destinationFile = file(""" + ccInputs.ReportDirectory + "/" + _jacocoExecPrefix + ".exec\"" + @")
		                    }
	                    }
                    }" + @"
                    task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
	                    dependsOn = subprojects.test
	                    executionData = files(subprojects.jacocoTestReport.executionData)
	                    sourceDirectories = files(subprojects.sourceSets.main.allSource.srcDirs)
	                    classDirectories = files()
	
	                    doFirst {
		                    subprojects.each {
			                    if (new File(""${it.sourceSets.main.output.classesDir}"").exists()) {
				                    logger.info(""Class directory exists in sub project: ${it.name}"")
				                    logger.info(""Adding class files ${it.sourceSets.main.output.classesDir}"")
				                    classDirectories += fileTree(dir: ""${it.sourceSets.main.output.classesDir}"", includes: jacocoIncludes, excludes: jacocoExcludes)
			                    } else {
				                    logger.error(""Class directory does not exist in sub project: ${it.name}"")
			                    }
		                    }
	                    }
	
	                    reports {
		                    html.enabled = true
                            xml.enabled = true    
		                    xml.destination """ + ccInputs.ReportDirectory + "/" + _summaryFile + @"""
		                    html.destination """ + ccInputs.ReportDirectory + @"""
	                    }
                    }
                    ";
            }
            else
            {
                enableJacoco = @"
                    allprojects { apply plugin: 'jacoco' }

                    allprojects {
	                    repositories {
                            mavenCentral()
                        }
                    }

//.........这里部分代码省略.........
开发者ID:codedebug,项目名称:vsts-agent,代码行数:101,代码来源:CodeCoverageEnablerForJacocoGradle.cs

示例12: ProcessBuildUpdateBuildNumberCommand

        private void ProcessBuildUpdateBuildNumberCommand(IExecutionContext context, string data)
        {
            ArgUtil.NotNull(context, nameof(context));
            ArgUtil.NotNull(context.Endpoints, nameof(context.Endpoints));

            ServiceEndpoint systemConnection = context.Endpoints.FirstOrDefault(e => string.Equals(e.Name, ServiceEndpoints.SystemVssConnection, StringComparison.OrdinalIgnoreCase));
            ArgUtil.NotNull(systemConnection, nameof(systemConnection));
            ArgUtil.NotNull(systemConnection.Url, nameof(systemConnection.Url));

            Uri projectUrl = systemConnection.Url;
            VssCredentials projectCredential = ApiUtil.GetVssCredential(systemConnection);

            Guid projectId = context.Variables.System_TeamProjectId ?? Guid.Empty;
            ArgUtil.NotEmpty(projectId, nameof(projectId));

            int? buildId = context.Variables.Build_BuildId;
            ArgUtil.NotNull(buildId, nameof(buildId));

            if (!String.IsNullOrEmpty(data))
            {
                // update build number within Context.
                context.Variables.Set(WellKnownBuildVariables.BuildNumber, data);

                // queue async command task to update build number.
                context.Debug($"Update build number for build: {buildId.Value} to: {data} at backend.");
                var commandContext = HostContext.CreateService<IAsyncCommandContext>();
                commandContext.InitializeCommandContext(context, StringUtil.Loc("UpdateBuildNumber"));
                commandContext.Task = UpdateBuildNumberAsync(commandContext,
                                                             projectUrl,
                                                             projectCredential,
                                                             projectId,
                                                             buildId.Value,
                                                             data,
                                                             context.CancellationToken);

                context.AsyncCommands.Add(commandContext);
            }
            else
            {
                throw new Exception(StringUtil.Loc("BuildNumberRequired"));
            }
        }
开发者ID:codedebug,项目名称:vsts-agent,代码行数:42,代码来源:BuildCommandExtension.cs

示例13: GitRemoteAdd

 // get remote set-url <origin> <url>
 public async Task<int> GitRemoteAdd(IExecutionContext context, string repositoryPath, string remoteName, string remoteUrl)
 {
     context.Debug($"Add git remote: {remoteName} to url: {remoteUrl} for repository under: {repositoryPath}.");
     return await ExecuteGitCommandAsync(context, repositoryPath, "remote", StringUtil.Format($"add {remoteName} {remoteUrl}"));
 }
开发者ID:codedebug,项目名称:vsts-agent,代码行数:6,代码来源:GitCommandManager.cs

示例14: GitVersion

        // git version
        public async Task<Version> GitVersion(IExecutionContext context)
        {
            context.Debug("Get git version.");
            Version version = null;
            List<string> outputStrings = new List<string>();
            int exitCode = await ExecuteGitCommandAsync(context, IOUtil.GetWorkPath(HostContext), "version", null, outputStrings);
            context.Debug($"git version ouput: {string.Join(Environment.NewLine, outputStrings)}");
            if (exitCode == 0)
            {
                // remove any empty line.
                outputStrings = outputStrings.Where(o => !string.IsNullOrEmpty(o)).ToList();
                if (outputStrings.Count == 1 && !string.IsNullOrEmpty(outputStrings.First()))
                {
                    string verString = outputStrings.First();
                    // we interested about major.minor.patch version
                    Regex verRegex = new Regex("\\d+\\.\\d+(\\.\\d+)?", RegexOptions.IgnoreCase);
                    var matchResult = verRegex.Match(verString);
                    if (matchResult.Success && !string.IsNullOrEmpty(matchResult.Value))
                    {
                        if (!Version.TryParse(matchResult.Value, out version))
                        {
                            version = null;
                        }
                    }
                }
            }

            return version;
        }
开发者ID:codedebug,项目名称:vsts-agent,代码行数:30,代码来源:GitCommandManager.cs

示例15: GitDisableAutoGC

 // git config gc.auto 0
 public async Task<int> GitDisableAutoGC(IExecutionContext context, string repositoryPath)
 {
     context.Debug("Disable git auto garbage collection.");
     return await ExecuteGitCommandAsync(context, repositoryPath, "config", "gc.auto 0");
 }
开发者ID:codedebug,项目名称:vsts-agent,代码行数:6,代码来源:GitCommandManager.cs


注:本文中的IExecutionContext.Debug方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。