Skip to content
This repository has been archived by the owner on Feb 12, 2019. It is now read-only.

Cannot create project #54

Open
nesteruk opened this issue Oct 16, 2013 · 20 comments
Open

Cannot create project #54

nesteruk opened this issue Oct 16, 2013 · 20 comments

Comments

@nesteruk
Copy link

JsonFx.Serialization.SerializationException was unhandled
HResult=-2146233079
Message=The encoding requested does not have a corresponding decoder
Source=EasyHttp
StackTrace:
at EasyHttp.Codecs.DefaultDecoder.ObtainDeserializer(String contentType) in d:\BuildAgent-02\work\f438280827ed948a\src\EasyHttp\Codecs\DefaultDecoder.cs:line 44
at EasyHttp.Codecs.DefaultDecoder.DecodeToStatic[T](String input, String contentType) in d:\BuildAgent-02\work\f438280827ed948a\src\EasyHttp\Codecs\DefaultDecoder.cs:line 22
at EasyHttp.Http.HttpResponse.StaticBody[T](String overrideContentType) in d:\BuildAgent-02\work\f438280827ed948a\src\EasyHttp\Http\HttpResponse.cs:line 111
at TeamCitySharp.Connection.TeamCityCaller.Post[T](String data, String urlPart)
at TeamCitySharp.TeamCityClient.CreateProject(String projectName)
at TeamCityDistributedSln.Program.Main(String[] args) in c:\Dropbox\Projects\Wild\TeamCityDistributedSln\TeamCityDistributedSln\Program.cs:line 17
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

@stack72
Copy link
Owner

stack72 commented Oct 16, 2013

Is this the only module on your system that doesn't work?

On Wednesday, 16 October 2013 at 17:21, Dmitri Nesteruk wrote:

JsonFx.Serialization.SerializationException was unhandled
HResult=-2146233079
Message=The encoding requested does not have a corresponding decoder
Source=EasyHttp
StackTrace:
at EasyHttp.Codecs.DefaultDecoder.ObtainDeserializer(String contentType) in d:\BuildAgent-02\work\f438280827ed948a\src\EasyHttp\Codecs\DefaultDecoder.cs:line 44
at EasyHttp.Codecs.DefaultDecoder.DecodeToStaticT (String%20input,%20String%20contentType) in d:\BuildAgent-02\work\f438280827ed948a\src\EasyHttp\Codecs\DefaultDecoder.cs:line 22
at EasyHttp.Http.HttpResponse.StaticBodyT (String%20overrideContentType) in d:\BuildAgent-02\work\f438280827ed948a\src\EasyHttp\Http\HttpResponse.cs:line 111
at TeamCitySharp.Connection.TeamCityCaller.PostT (String%20data,%20String%20urlPart)
at TeamCitySharp.TeamCityClient.CreateProject(String projectName)
at TeamCityDistributedSln.Program.Main(String[] args) in c:\Dropbox\Projects\Wild\TeamCityDistributedSln\TeamCityDistributedSln\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStartContext(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:


Reply to this email directly or view it on GitHub (#54).

@nesteruk
Copy link
Author

Yep. This is for client.CreateProject(). Also, I couldn't find any reference to the fact that all projects are children of the root project, nor did I find an API for creating subprojects. But this could be just my oversight.

@stack72
Copy link
Owner

stack72 commented Oct 16, 2013

oh so this os for TeamCity 8.0?

On Wednesday, 16 October 2013 at 18:11, Dmitri Nesteruk wrote:

Yep. This is for client.CreateProject(). Also, I couldn't find any reference to the fact that all projects are children of the root project, nor did I find an API for creating subprojects. But this could be just my oversight.


Reply to this email directly or view it on GitHub (#54 (comment)).

@nesteruk
Copy link
Author

yep

@stack72
Copy link
Owner

stack72 commented Oct 16, 2013

ok makes sense - I need to look at this immediately. Thanks for bringing this up to me

Paul

On Wednesday, 16 October 2013 at 18:15, Dmitri Nesteruk wrote:

yep


Reply to this email directly or view it on GitHub (#54 (comment)).

@nesteruk
Copy link
Author

anything I can do to help speed this up? is this a quick fix or does it require a big redesign?

@stack72
Copy link
Owner

stack72 commented Oct 19, 2013

Hey

I am looking at this right now - I am trying to come up with a way that will allow the creation of a project / subproject for 8.0 that is also compatible with 7.x

Paul

On Saturday, 19 October 2013 at 12:50, Dmitri Nesteruk wrote:

anything I can do to help speed this up? is this a quick fix or does it require a big redesign?


Reply to this email directly or view it on GitHub (#54 (comment)).

@satyaprakashv
Copy link

satyaprakashv commented Mar 20, 2018

Hey stack72,

I am using TC 10 and using this to automate the TC Project creation and creating build configurations and Build Steps from my automation tool. I need some urgent help.

I am also getting the same error while creating Build steps using this below method-
public void PostRawBuildStep(BuildTypeLocator locator, string rawXml)
(FYI Build Step is getting created in TC and then after it is throwing the error, so my tool could not execute next set of code)

Error:
The encoding requested does not have a corresponding decoder

at EasyHttp.Codecs.DefaultDecoder.ObtainDeserializer(String contentType)
at EasyHttp.Codecs.DefaultDecoder.DecodeToStatic[T](String input, String contentType)
at EasyHttp.Http.HttpResponse.StaticBody[T](String overrideContentType)
at TeamCityHelper.Connection.TeamCityCaller.Post[T](String data, String contenttype, String urlPart, String accept) in C:\work\CodeBase\GIT\TeamCityAutomation\src\TeamCitySharp\Connection\TeamCityCaller.cs:line 149
at TeamCityHelper.Connection.TeamCityCaller.PostFormat[T](Object data, String contenttype, String accept, String urlPart, Object[] parts) in C:\work\CodeBase\GIT\TeamCityAutomation\src\TeamCitySharp\Connection\TeamCityCaller.cs:line 45
at TeamCityHelper.ActionTypes.BuildConfigs.PostRawBuildStep(BuildTypeLocator locator, String rawXml) in C:\work\CodeBase\GIT\TeamCityAutomation\src\TeamCitySharp\ActionTypes\BuildConfigs.cs:line 109
at DevOpsAutomation.TeamCityUI.btnCreateProject_Click(Object sender, EventArgs e)

@mavezeau
Copy link

Hi satyaprakashv
The main maintener of this project didn't support this project since many year, I recommend to use my fork and the current version was not supported teamcity 10.

In the same time, it's possible to use directly the latest version from the nuget.org

Link to nuget.org: https://www.nuget.org/packages/TeamCitySharp-forked-mavezeau/
Link to github: https://github.com/mavezeau/TeamCitySharp

Regards!
Marc-Andre Vezeau

@satyaprakashv
Copy link

Awesome .. Thanks a lot Marc..
Seems there are more new methods available now. Hope all will support my requirements..

Thanks
Satya

@mavezeau
Copy link

Yes, I added many new features if you missing some stocks just contact me on my fork :)

@satyaprakashv
Copy link

Hey mavezeau,
I could not see to create an issue/comment on your fork page:
I am getting the same error as above..

my XML for create anew build step is as below:

@mavezeau
Copy link

mavezeau commented Mar 20, 2018

I dont see your xml but I send a little version of code... In the same time, I found an issue in the code ... I already fixed the bug and I regenerate a new version.

We need to wait that nuget approved the package , but it's already available
https://www.nuget.org/packages/TeamCitySharp-forked-mavezeau/1.0.56

E.g. of the code to create a new project, new build config and build step
`var server = "server";
var username = "admin";
var password = "admin";
var m_teamCityClient = new TeamCityClient(server);

m_teamCityClient.Connect(username, password);
var p = m_teamCityClient.Projects.Create("NewProject", "TeamcityDashboardScenario");
var bt = m_teamCityClient.BuildConfigs.CreateConfigurationByProjectId(p.Id, "testNewConfig");
var xml = "< step type="simpleRunner">" +
"< properties>" +
"< property name="script.content" value="@echo off echo Step1 touch step1.txt" />" +
"< property name="teamcity.step.mode" value="default" />" +
"< property name="use.custom.script" value="true" />" +
"< /properties>" +
"< /step>";
m_teamCityClient.BuildConfigs.PostRawBuildStep(BuildTypeLocator.WithId(bt.Id),xml );`

PS :I added a space before each tag ex "< step" because the editor does not display the tag...
Regards,
Marc-André

@satyaprakashv
Copy link

Hey Mark,
I found one more issue while creating VCS-Roots..
I Used method my code look like this below:

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

            TeamCityWrapper.DomainEntities.Properties properties= new TeamCityWrapper.DomainEntities.Properties();
            properties.Add("agentCleanFilesPolicy", "ALL_UNTRACKED");
            vcsroot.Properties = properties;

client.VcsRoots.SetVcsRootValue(vcsroot, VcsRootValue.ProjectId, project.Id);

Error:
Forbidden Error: Forbidden
HTTP: Forbidden
URL: http://localhost:90/httpAuthTest33_vcsroot1_01

<title>Apache Tomcat/7.0.68 - Error report</title><style></style>

HTTP Status 403 -


type Status report

message

description Access to the specified resource has been forbidden.


Apache Tomcat/7.0.68

Stack Track:
at TeamCityWrapper.Connection.TeamCityCaller.ThrowIfHttpError(HttpResponse response, String url) in C:\work\CodeBase\GIT\TeamCityAutomation\src\TeamCityWrapper\Connection\TeamCityCaller.cs:line 238
at TeamCityWrapper.Connection.TeamCityCaller.MakePutRequest(Object data, String contenttype, String urlPart, String accept) in C:\work\CodeBase\GIT\TeamCityAutomation\src\TeamCityWrapper\Connection\TeamCityCaller.cs:line 216
at TeamCityWrapper.Connection.TeamCityCaller.Put(Object data, String contenttype, String urlPart, String accept) in C:\work\CodeBase\GIT\TeamCityAutomation\src\TeamCityWrapper\Connection\TeamCityCaller.cs:line 178
at TeamCityWrapper.Connection.TeamCityCaller.PutFormat(Object data, String contenttype, String urlPart, Object[] parts) in C:\work\CodeBase\GIT\TeamCityAutomation\src\TeamCityWrapper\Connection\TeamCityCaller.cs:line 66
at TeamCityWrapper.ActionTypes.VcsRoots.SetVcsRootValue(VcsRoot vcsRoot, VcsRootValue field, Object value) in C:\work\CodeBase\GIT\TeamCityAutomation\src\TeamCityWrapper\ActionTypes\VcsRoots.cs:line 56
at DevOpsAutomation.TeamCityUI.btnCreateProject_Click(Object sender, EventArgs e) in C:\work\CodeBase\GIT\TeamCityAutomation\DevOpsAutomation\TeamCityUI.cs:line 231

@mavezeau
Copy link

Hi Satya,

I made a little refactoring to fix your issue.

I created new methods :
for VcsRoot:

  • VcsRoot CreateVcsRoot(VcsRoot configurationName, string projectId);
  • void SetConfigurationProperties(VcsRoot vcsRootId, string key, string value);
  • void DeleteProperties(VcsRoot vcsRootId, string parameterName);
  • void DeleteVcsRoot(VcsRoot vcsRoot);

And I modified
for VcsRoot:

  • (Fix) void SetVcsRootValue(VcsRoot vcsRoot, VcsRootValue field, object value)

How to use the new stuff:

`

  var project = m_client.Projects.ById("Test");
  var vcsroot = new VcsRoot
  {
    Id = project.Id + "_vcsroot1_01",
    Name = project.Name + "_vcsroot1",
    VcsName = "jetbrains.git",
    Project = new Project {Id = project.Id}
  };

  var 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);

`

The new version was already avalaible.

Regards,

@satyaprakashv
Copy link

Hey Marc,

Is there any API method to set Sonar Qube server properties. see this below, I have installed a plugin and that show as a TAB in TeamCity,I have added all properties manually, but how can I configure all these properties using the TC API?

image

Thanks and Regards
Satya

@satyaprakashv
Copy link

Hi Mavezeau,

Reference to the above post I have created one method to post raw XML for creating a ProjectFeature for setting up SonarQube Server Profile using the Rest API -

http://<teamcity.domain.name>/app/rest/projects//projectFeatures

When we POST the below XML (consisting of SonarQube Server Profile settings) to REST API, it gives an error that the type parameter cannot be empty (Attribute of projectFeature element).
However, when I provide a random type (say "sonar-plugin") the project extension gets added to - C:\ProgramData\JetBrains\TeamCity\config\projects<projectName>\project-config.xml but the SonarQuebe Server profile does not created and is not visible under SonarQube Server. Refer the screeshot below
The crux of the issue is that the SonarQube Server profile is detected as a legitimate ProjectFeature only when the type parameter is left Empty. But irony of the API is that it does not allow to post the XML with an empty type attribute.
Any help in the issue or pointer to work around would be greatly appreciated. Thanks in advance !











@mavezeau
Copy link

mavezeau commented Apr 9, 2018

Hi Satya,
Sorry for the delay. I didn`t see your previous message.

I never try SonarQube with Teamcity, I dont know if it is an issue with sonar, the rest api or your sonar teamcity plugin ... Normally, this rest wrapper didnt validate or modify the xml sent, for this reason I think it`s more and issue with the sonar plugin.

But I will check soon in my side. I don`t know if I will have time this week to check this.

At the same time, is It possible to configure your server manually and just assign this projectFeature on your project ?

@satyaprakashv
Copy link

Hi Mavezeau,
Thanks for your prompt response...
I am able to create project feature by posting the XML, real issue is
type parameter cannot be empty (Attribute of projectFeature element) while calling the API.

projectFeature id="PROJECT_EXT_1" type="sonar-plugin"
However, when I provide a type (say "sonar-plugin") the project extension gets added into TC but that will actualy not visible in TC Project Settings. other wise it is visible. I feeling that is TC issue. I have posted a issue there and waiting for any response.

I thought if I could get some help from you.

Regards
Satya

@mavezeau
Copy link

mavezeau commented Apr 9, 2018

Hi Satya,

I added the capability to create and delete a new Project Feature on the latest version 1.0.59.
https://www.nuget.org/packages/TeamCitySharp-forked-mavezeau/1.0.59

On Project:
ProjectFeatures GetProjectFeatures(string projectLocatorId);
ProjectFeature GetProjectFeatureByProjectFeature(string projectLocatorId, string projectFeatureId);
ProjectFeature CreateProjectFeature(string projectId, ProjectFeature projectFeature);
void DeleteProjectFeature(string projectId, string projectFeatureId);

Just check if it's working with the new stuff...
Regards

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants