public static Agent BuildAgentFactory(ArtifactoryBuild task)
        {
            if (task.TfsActive != null && task.TfsActive.Equals("True"))
            {
                IEnumerable <String> tfsCollectionURI = BuildEngineExtensions.GetEnvironmentVariable(task.BuildEngine, "TF_BUILD_COLLECTIONURI", false);
                if (tfsCollectionURI != null)
                {
                    return(new AgentTFS(task));
                }
                else
                {
                    return(new AgentTFS2015(task));
                }
            }

            return(new AgentMSBuild(task));
        }
        public override string BuildAgentUrl() 
        {
            StringBuilder tfsUrl = new StringBuilder("$(TF_BUILD_COLLECTIONURI)/$(TEAM_PROJECT)/_build#buildUri=$(TF_BUILD_BUILDURI)&_a=summary");
            IEnumerable<String> tfsCollectionURI = BuildEngineExtensions.GetEnvironmentVariable(buildEngine, "TF_BUILD_COLLECTIONURI", false);
            IEnumerable<String> tfsTeamProject = BuildEngineExtensions.GetEnvironmentVariable(buildEngine, "TEAM_PROJECT", false);
            IEnumerable<String> tfsBuildURI = BuildEngineExtensions.GetEnvironmentVariable(buildEngine, "TF_BUILD_BUILDURI", false);

            if (tfsCollectionURI != null)
                tfsUrl = tfsUrl.Replace("$(TF_BUILD_COLLECTIONURI)", tfsCollectionURI.First());

            if (tfsTeamProject != null)
                tfsUrl = tfsUrl.Replace("$(TEAM_PROJECT)", tfsTeamProject.First());

            if (tfsBuildURI != null)
                tfsUrl = tfsUrl.Replace("$(TF_BUILD_BUILDURI)", tfsBuildURI.First());

            return tfsUrl.ToString();
        }
        /// <summary>
        /// Replacing all the MSBuild properties placeholder $()
        /// </summary>
        /// <param name="artifactoryConfigurationFile">Full file path</param>
        /// <param name="task">MSBuild implemented Task</param>
        /// <returns>New file content after replacement.</returns>
        public static StringBuilder MsbuildInterpreter(FileInfo artifactoryConfigurationFile, ArtifactoryBuild task)
        {
            StringBuilder xmlContent = new StringBuilder(artifactoryConfigurationFile.OpenText().ReadToEnd());

            Regex           propertiesPattern = new Regex(@"(\$\([\w]+\))");
            MatchCollection matchCollection   = propertiesPattern.Matches(xmlContent.ToString());

            foreach (var match in matchCollection)
            {
                string propertyKey = match.ToString().Replace("$(", string.Empty).Replace(")", string.Empty);
                IEnumerable <String> msbuildProperty = BuildEngineExtensions.GetEnvironmentVariable(task.BuildEngine, propertyKey, false);
                if (msbuildProperty != null)
                {
                    xmlContent = xmlContent.Replace(match.ToString(), msbuildProperty.First());
                }
            }
            return(xmlContent);
        }
Ejemplo n.º 4
0
        public override string BuildAgentUrl()
        {
            StringBuilder        tfsUrl           = new StringBuilder("$(SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)/$(SYSTEM_TEAMPROJECT)/_build#buildId=$(BUILD_BUILDID)&_a=summary");
            IEnumerable <String> tfsCollectionURI = BuildEngineExtensions.GetEnvironmentVariable(buildEngine, "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", false);
            IEnumerable <String> tfsTeamProject   = BuildEngineExtensions.GetEnvironmentVariable(buildEngine, "SYSTEM_TEAMPROJECT", false);
            IEnumerable <String> tfsBuildURI      = BuildEngineExtensions.GetEnvironmentVariable(buildEngine, "BUILD_BUILDID", false);

            if (tfsCollectionURI != null)
            {
                tfsUrl = tfsUrl.Replace("$(SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)", tfsCollectionURI.First());
            }

            if (tfsTeamProject != null)
            {
                tfsUrl = tfsUrl.Replace("$(SYSTEM_TEAMPROJECT)", tfsTeamProject.First());
            }

            if (tfsBuildURI != null)
            {
                tfsUrl = tfsUrl.Replace("$(BUILD_BUILDID)", tfsBuildURI.First());
            }

            return(tfsUrl.ToString());
        }