コード例 #1
0
        public VcsRoot AttachVcsRoot(BuildTypeLocator locator, VcsRoot vcsRoot)
        {
            var xml = string.Format(@"<vcs-root-entry><vcs-root id=""{0}""/></vcs-root-entry>", vcsRoot.Id);

            return(_caller.PostFormat <VcsRoot>(xml, HttpContentTypes.ApplicationXml, HttpContentTypes.ApplicationJson,
                                                "/app/rest/buildTypes/{0}/vcs-root-entries", locator));
        }
コード例 #2
0
        public void it_throws_exception_create_new_vsc_forbidden()
        {
            var project = m_client.Projects.ById(m_goodProjectId);

            VcsRoot vcsroot = new VcsRoot();
            vcsroot.Id = project.Id + "_vcsroot1_01";
            vcsroot.Name = project.Name + "_vcsroot1";
            vcsroot.VcsName = "jetbrains.git";
            vcsroot.Project = new Project();
            vcsroot.Project.Id = project.Id;

            Properties properties = new Properties();

            properties.Add("agentCleanFilesPolicy", "IGNORED_ONLY");
            vcsroot.Properties = properties;

            try
            {
                m_client.VcsRoots.CreateVcsRoot(vcsroot, project.Id);
            }
            catch (HttpException e)
            {
                Assert.That(e.ResponseStatusCode == HttpStatusCode.Forbidden);
            }
            catch (Exception e)
            {
                Assert.Fail("CreateNewVsc faced an unexpected exception", e);
            }
        }
コード例 #3
0
ファイル: TeamCityBuildType.cs プロジェクト: t081as/nuke
        public override void Write(CustomFileWriter writer)
        {
            writer.WriteLine($"object {Id} : BuildType({{");
            using (writer.Indent())
            {
                writer.WriteLine($"name = {Name.DoubleQuote()}");

                if (Description != null)
                {
                    writer.WriteLine($"description = {Description.DoubleQuote()}");
                }

                if (IsComposite)
                {
                    writer.WriteLine("type = Type.COMPOSITE");
                }

                VcsRoot.Write(writer);
                WriteArtifacts(writer);

                if (!IsComposite)
                {
                    WriteSteps(writer);
                }

                WriteParameters(writer);
                WriteTriggers(writer);
                WriteDependencies(writer);
            }

            writer.WriteLine("})");
        }
コード例 #4
0
        public void it_create_new_vsc()
        {
            var project = m_client.Projects.ById(m_goodProjectId);

            VcsRoot vcsroot = new VcsRoot();
            vcsroot.Id = project.Id + "_vcsroot1_01";
            vcsroot.Name = project.Name + "_vcsroot1";
            vcsroot.VcsName = "jetbrains.git";
            vcsroot.Project = new Project();
            vcsroot.Project.Id = project.Id;

            Properties properties = new Properties();

            properties.Add("agentCleanFilesPolicy", "IGNORED_ONLY");
            vcsroot.Properties = properties;

            var vcsroot2 = m_client.VcsRoots.CreateVcsRoot(vcsroot, project.Id);

            m_client.VcsRoots.SetVcsRootValue(vcsroot2, VcsRootValue.Name, "TestChangeName");

            m_client.VcsRoots.SetConfigurationProperties(vcsroot2, "agentCleanFilesPolicy", "ALL_UNTRACKED");
            m_client.VcsRoots.SetConfigurationProperties(vcsroot2, "tt", "tt2");
            m_client.VcsRoots.DeleteProperties(vcsroot2, "tt");
            m_client.VcsRoots.DeleteVcsRoot(vcsroot2);
        }
コード例 #5
0
        public IVcsManager CreateVcsManagerFrom(Settings settings, VcsRoot vcsRoot)
        {
            if (vcsRoot.Type == Vcs.Git)
            {
                return new GitManager(settings.WorkingFolder, settings.GitPath, vcsRoot.Url, vcsRoot.Name);
            }

            return null;
        }
コード例 #6
0
        public void Should_create_a_vcs_manager_from_the_given_information()
        {
            var settings = new Settings();
            var vcsRoot = new VcsRoot { Type = Vcs.Git };

            var vcsManager = new VcsManagerFactory().CreateVcsManagerFrom(settings, vcsRoot);

            Assert.That(vcsManager, Is.InstanceOf<GitManager>());
        }
コード例 #7
0
ファイル: VcsRoots.cs プロジェクト: zabbius/TeamCitySharp
        public VcsRoot AttachVcsRoot(BuildTypeLocator locator, VcsRoot vcsRoot)
        {
            var data = new VcsRootEntry {
                VcsRoot = new VcsRoot {
                    Id = vcsRoot.Id
                }
            };

            return(m_caller.PostFormat <VcsRoot>(data, HttpContentTypes.ApplicationJson, HttpContentTypes.ApplicationJson,
                                                 "/buildTypes/{0}/vcs-root-entries", locator));
        }
コード例 #8
0
        public VcsRoot CreateVcsRoot(VcsRoot vcsRoot, string projectId)
        {
            var writer =
                new JsonWriter(
                    new DataWriterSettings(new JsonResolverStrategy()));
            var data = writer.Write(vcsRoot);

            return(m_caller.PostFormat <VcsRoot>(data, HttpContentTypes.ApplicationJson,
                                                 HttpContentTypes.ApplicationJson, "/app/rest/vcs-roots",
                                                 projectId));
        }
コード例 #9
0
        public async Task <VcsRoot> Execute(VcsRoot vcsRoot, string buildId)
        {
            var serializerSettings =
                new JsonSerializerSettings
            {
                ContractResolver  = new CamelCasePropertyNamesContractResolver(),
                NullValueHandling = NullValueHandling.Ignore
            };
            var json = JsonConvert.SerializeObject(vcsRoot, serializerSettings);

            vcsRoot = await _teamcityService.CreateVcsRoot(json);

            return(await _attachVcsRootCommand.Execute(vcsRoot.Id, buildId));
        }
コード例 #10
0
        public async Task <VcsCommit> GetCommitInformationByBuildId(long buildId)
        {
            Log.Info(string.Format("Get Commit Information for Build: {0}", buildId));
            Build build = await _client.Builds.ById(buildId);

            if (!build.Revisions.Any())
            {
                Log.Debug("Build doesn't have any VCS data");
                return(null);
            }

            BuildConfig currentBuildConfig = await _client.BuildConfigs.GetByConfigurationId(build.BuildConfig.Id);

            Log.Debug("Build Loaded from TeamCity");

            string commitSha = build.Revisions.First().Version;

            Log.Debug(string.Format("Commit SHA from first Revision: {0}", commitSha));

            //use VCS Root from the current state of Build Config, instead of the old version, as it could have been moved to a different repository
            var vcsRootId = currentBuildConfig.VcsRootEntries.VcsRootEntry.First().VcsRoot.Id;

            Log.Debug(string.Format("Get VCSRoot by Id: {0}", vcsRootId));
            VcsRoot vcsRoot = await _client.VcsRoots.ById(vcsRootId);

            Log.Debug(string.Format("VCSRoot: {0}", vcsRoot));
            //build configs don't have resolved system parameters, so manually inject it as a workaround.
            //Another way to get resolved system parameters is to use ResultingProperties API call for the latest build of the config
            currentBuildConfig.Parameters.Property.Add(new Property
            {
                Name  = ParameterName.SystemTeamcityProjectName,
                Value = currentBuildConfig.Project.Name
            });
            VcsCommit commit = new VcsCommit(vcsRoot, currentBuildConfig.Parameters.Property, commitSha);

            return(commit);
        }
コード例 #11
0
        public void it_returns_vcs_details_when_passing_vcs_root_id(string vcsRootId)
        {
            VcsRoot rootDetails = _client.VcsRoots.ById(vcsRootId);

            Assert.That(rootDetails != null, "Cannot find the specific VCSRoot");
        }
コード例 #12
0
ファイル: VcsRoots.cs プロジェクト: zabbius/TeamCitySharp
 public void DeleteVcsRoot(VcsRoot vcsRoot)
 {
     m_caller.DeleteFormat("/vcs-roots/id:{0}", vcsRoot.Id);
 }
コード例 #13
0
ファイル: VcsRoots.cs プロジェクト: zabbius/TeamCitySharp
 public VcsRoot CreateVcsRoot(VcsRoot vcsRoot, string projectId)
 {
     return(m_caller.PostFormat <VcsRoot>(vcsRoot, HttpContentTypes.ApplicationJson,
                                          HttpContentTypes.ApplicationJson, "/vcs-roots",
                                          projectId));
 }
コード例 #14
0
ファイル: VcsRoots.cs プロジェクト: zabbius/TeamCitySharp
 public void DeleteProperties(VcsRoot vcsRoot, string parameterName)
 {
     m_caller.DeleteFormat("/vcs-roots/id:{0}/properties/{1}", vcsRoot.Id, parameterName);
 }
コード例 #15
0
ファイル: VcsRoots.cs プロジェクト: zabbius/TeamCitySharp
 public void SetConfigurationProperties(VcsRoot vcsRoot, string key, string value)
 {
     m_caller.PutFormat(value, HttpContentTypes.TextPlain, "/vcs-roots/id:{0}/properties/{1}", vcsRoot.Id, key);
 }
コード例 #16
0
ファイル: VcsRoots.cs プロジェクト: zabbius/TeamCitySharp
 public void SetVcsRootValue(VcsRoot vcsRoot, VcsRootValue field, object value)
 {
     m_caller.PutFormat(value, HttpContentTypes.TextPlain, "/vcs-roots/id:{0}/{1}", vcsRoot.Id,
                        ToCamelCase(field.ToString()));
 }
コード例 #17
0
 public void SetVcsRootField(VcsRoot vcsRoot, VcsRootField field, object value)
 {
     _caller.PutFormat(value, "/app/rest/vcs-roots/id:{0}/{1}", vcsRoot.Id, ToCamelCase(field.ToString()));
 }