Create build configuration from existing template in TeamCity using REST API - rest

I'm trying to create build configuration for a project in TeamCity 8.0 using REST API. However instead of creating a new configuration I want to copy from an existing build configuration template. Basically, I'm looking to implement before option present in TeamCity web interface:
TeamCity REST API documentation is not extensive and it does not provide any details about how to create build configuration using existing template via REST API. Any input on how this can be done using REST API ?

I believe TC 8.x and TC 9.x REST APIs are pretty similar. This example was written for TC 9.x.
I don't know if you have sorted this out, but (for the record) you have to do what the "Create a new build configuration with all settings" says. Basically, you have to create an XML with a format like this:
<buildType id="YourBuildID" name="YourBuildName" projectId="TheProjectIDThatOwnsThis" >
<project id="TheProjectIDThatOwnsThis" name="TheProjectName" parentProjectId="TheProjectParent" href="TheProjectHREFValue" webUrl="TheWebURLOfTheProejct"
/>
<template id="TemplateID" name="TemplateName" templateFlag="true" projectName="ProjectThatHasTheTemplate" projectId="ProjectThatHasTheTemplate" href="TemplateHRef" />
<vcs-root-entries>
<!--vcs-root-entry elements are not necessary-->
</vcs-root-entries>
<settings>
</settings>
<parameters>
</parameters>
<steps>
</steps>
<features>
</features>
<triggers>
</triggers>
<snapshot-dependencies/>
<artifact-dependencies/>
<agent-requirements/>
<builds href="BuildConfigurationHREF" />
</buildType>
And do a POST to this URL: http://TCServerName:Port/httpAuth/app/rest/buildTypes
That is the XML expected by TeamCity, so it's up to you in which programming language you will create it. I have done this with C#/LINQ to XML and worked just fine.
Hope this helps.

Related

Deployment according to environment and user privileges through TFS CI

I have trying to implement CI for my desktop .NET application. But I am stuck at how to implement some stuff.
According to the requirements, I need to implement a filter while releasing the build according to user privileges and also filter the funtionalities that need not be installed on production.
I used to do this manually using a manifest.xml but now it seems a bit tidious to implement the same through TFS without using the Manifest.
My manifest looks like this:
<?xml version="1.0" encoding="Windows-1252"?>
<Manifest UpdaterVersion="3.33.7.717">
<f t="DLL" v="0.86.5.0" p="Module1.dll" />
<f t="DLL" v="1.26.2.123" d="true" x="true" p="File\Module2.dll" />
In this example "d" is for dll not be installed on production and "x" is for power user only.
Can anyone help me find a solution for this?

IBM Notes: Eclipse Plugin deployment to framework directory

I am not totally sure, if this question is in the right forum here, but as it is about a development environment and deploying developments I think it is save to ask.
I have a plugin for the IBM Notes client that I need to install silently in the background.
I used "CustomizeAddon.exe" to create a package and created an install.addon.xml with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<ibm-portal-composite>
<domain-object name="com.ibm.rcp.installmanifest">
<object-data>
<install>
<installfeature id="Jabber4Notes" required="true">
<requirements>
<feature id="com.endava.jabber4notes.feature"
version="2.11.8.298" match="compatible"
shared="true" mergeaction="add"
url="jar:${installer.root}/updateSite.zip!/" />
<feature id="com.endava.jabber4notes.IMPFragmentFeature"
version="2.11.8.298" match="compatible"
shared="true" mergeaction="add"
url="jar:${installer.root}/updateSite.zip!/" />
</requirements>
</installfeature>
</install>
</object-data>
</domain-object>
</ibm-portal-composite>
But although I use the parameter shared="true" the plugin always installs to the workspace directory instead of the feature- directory.
How can I change this behaviour?
Make sure to have write permissions on the shared site.
If that's not the problem try to use colocation affinity to specify that the deployment site should be the same of another plugin; com.ibm.rcp.site.anchor.shared.feature is always installed on the shared site so you could add this:
colocation-affinity="com.ibm.rcp.site.anchor.shared.feature"
Here you can find more information regarding this topic: LINK

How to make changes in management concole regarding WSO2 Identity Server v5.0.0

I have download all patches (upto patch008), by using TortiseSVN svn checkout the following //svn.wso2.org/repos/wso2/carbon/kernel/branches/4.2.0/ and //svn.wso2.org/repos/wso2/carbon/platform/tags/turing-chunk11/
Then exported above folder to another location D:\platform, D:\productssource and build them with Build successful message !.
Now I want to makes changes in Management Console of WSO2IS v5.0 Under Entitlement Sub menu such as PAP, PDP and MyOwnCreatedPAP, which look like this 1.
To achieve above mentioned requirement, what steps should I followed in Eclipse IDE to makes changes in source code, plz mentioned them in step by step, as I am newbie.
For this you have to write a custom Carbon component UI bundle. You need to include a component.xml file in src/main/resources/META-INF/ folder of your component with content similar to below to add a menu item.
<component xmlns="http://products.wso2.org/carbon">
<menus>
<menu>
<id>studentmgt_menu</id>
<i18n-key>student.menu</i18n-key>
<i18n-bundle>org.wso2.carbon.student.mgt.ui.i18n.Resources</i18n-bundle>
<parent-menu>manage_menu</parent-menu>
<link>../student-mgt/index.jsp</link>
<region>region1</region>
<order>50</order>
<style-class>manage</style-class>
<icon>../student-mgt/images/students.gif</icon>
<require-permission>/permission/protected/manage</require-permission>
</menu>
</menus>
</component>
Follow this guide for a complete tutoriol on how to write a custom Carbon component and create a UI bundle.

wso2is custom authenticationendpoint, redirect page not used

I am developing saml sso using wso2is. I customized the authentication endpoint according the blog post below 1. Basically I just deployed a war on my server and configured application-authenticators.xml to use it:
<Authenticators>
<Authenticator name="BasicAuthenticator" disabled="false" factor="1">
<!-- <Status value="10" loginPage="/authenticationendpoint/login.do" /> -->
<Status value="10" loginPage="https://servlet.example.com/customlogin/login.do" />
</Authenticator>
</Authenticators>
login is working fine, my custom login-page sends a form to "https://servlet.example.com/idp/commonauth" which redirects me to my sp. but I also want to customize the redirect-page after the login. in the custom endpoint there is a file named 'samlsso_redirect.jsp' which looks like it should do the work but its contents are ignored.
strangely 'samlsso_redirect.jsp' the the bundled authentication endpoint is also ignored.
I have also downloaded the sources of wso2is and found org.wso2.carbon.identity.sso.saml.servlet.SAMLSSOProviderServlet hard codes the redirect message in the sendResponse() method.
Does somebody know how it is working and what I am missing here? How can I customize the redirect message?
http://dulanja.blogspot.sk/2014/01/wso2-is-samlsso-customizing-login-page.html
If you are using WSO2IS 5.0.0 version or higher version, You can simplify edit html file which can be found at IS_HOME\repository\resources\security\sso_redirect.html
Following applies to WSO2IS 4.6.0 and older versions
It seems to be that redirect page is can not be customized by using some extension. Please see this jira
However You can do as following if you want to customize it in 4.6.0...
svn checkout https://svn.wso2.org/repos/wso2/carbon/platform/branches/turing/components/identity/org.wso2.carbon.identity.sso.saml/4.2.2
In src/main/java/org/wso2/carbon/identity/sso/saml/servlet/SAMLSSOProviderServlet.java you have to modify the HTML getting printed in sendResponse() method.
Build the component using maven and place as a patch in wso2is-4.6.0/repository/components/patches. Copy jar file into any patch directory
Restart the server
note : The built jar name appears as: org.wso2.carbon.identity.sso.saml-4.2.2.jar. Make sure to rename it to org.wso2.carbon.identity.sso.saml_4.2.2.jar (notice that the dash is replaced by an underscore) before placing in the patch folder.
If you are using IS 5.0 then you need to modify this page:
IS_HOME\repository\resources\security\sso_redirect.html

TFS2010 Build Definition to Deploy to multiple servers?

I've been looking into TFS2010 new build and deployment features with MSDeploy. So far everything is going well (although its been hard to find information about specific scenarios).
Can I modify my Build Definition to specify 2 or more servers to deploy to? What I need to do is deploy to multiple servers (as I have two in my testing environment which uses a NLB).
What I have now is a Build definition which Builds, runs my tests, and then Deploys to ONE of my testing servers (which has the MsDeployAgentService running on it). It works fine, and each web project is deployed as configured in its project file. The MSBuild Arguments I use are:
* /p:DeployOnBuild=True
* /p:DeployTarget=MsDeployPublish
* /p:MSDeployServiceURL=http://oawww.testserver1.com.au/MsDeployAgentService
* /p:CreatePackageOnPublish=True
* /p:MsDeployPublishMethod=RemoteAgent
* /p:AllowUntrustedCertificated=True
* /p:UserName=myusername
* /p:Password=mypassword
NB: I dont use /p:DeployIISAppPath="xyz" as it doesnt deploy all my projects and overrides my project config.
Can I add another build argument to get it to call more than one MSDeployServiceURL? Like something like a second /p:MSDeployServiceURL argument that specifies another server?
Or do I have to look for another solution, such as editing the WF?
I saw an almost exact same question here posted 2 months ago: TFS 2010 - Deploy to Multiple Servers After Build , so it doesn't look like I'm the only one trying to solve this.
I also posted on the IIS.NET forums where MSDeploy is discussed: http://forums.iis.net/t/1170741.aspx . It's had quite a lot of views, but again, no answers.
You don't have to build the project twice to deploy to two servers. The build process will build a set of deployment files. You can then use the InvokeProcess to deploy to multiple servers.
First create a variable named ProjectName. Then add an Assign activity to the "Compile the Project" sequence. This is located in the "Try to Compile the Project" sequence. Here are the properties of the Assign:
To: ProjectName
Value: System.IO.Path.GetFileNameWithoutExtension(localProject)
Here are the properties of our InvokeProcess activity that deploys to the test server:
Arguments: "/y /M:<server> /u:<domain>\<user> /p:<password>"
FileName: String.Format("{0}\{1}.deploy.cmd", BuildDetail.DropLocation, ProjectName)
You will need to change <server>, <domain>, <user>, and <password> to the values that reflect your environment.
If you need to manually deploy to a server you can run the command below from your build folder:
deploy.cmd /y /M:<server> /u:<domain>\<user> /p:<password>
I couldn't find the solution I was looking for, but here's what I came up with in the end.
I wanted to keep the solution simple and configurable within the TFS arguments while at the same time staying in line with the already provided MSBuildArguments method which has been promoted a lot. So I created a new Build Template, and added a new TFS WorkFlow Argument called MSBuildArguments2 in the Arguments tab of the WorkFlow.
I searched through the BuildTemplate WorkFlow for all occurances of the MSBuildArguments (there were two occurances).
The two tasks that use MSBuildArguments are called Run MSBuild for Project. Directly below this task, I added a new "If" block with the condition:
Not String.IsNullOrEmpty(MSBuildArguments2)
I then copied the "Run MSBuild for Project" task and pasted it into the new If's "Then" block, updating its title accordingly. You'll also need to update the new Task's ConmmandLineArguments property to use your new Argument.
CommandLineArguments = String.Format("/p:SkipInvalidConfigurations=true {0}", MSBuildArguments2)
After these modifications, the WorkFlow looks like this:
Save and Check In the new WorkFlow. Update your Build Definition to use this new WorkFlow, then in the build definition's Process tab you will find a new section called Misc with the new argument ready to be used. Because I'm simply using this new argument for deployment, I copied the exact same arguments I used for MSBuild Arguments and updated the MSDeployServiceURL to my second deployment server.
And that's that. I suppose a more elegant method would be to convert MSBuildArguments into an array of strings and then loop through them during the WorkFlow process. But this suits our 2 server requirements.
Hope this helps!
My solution to this is a new Target that runs after Package. Each project that needs to produce a package includes this targets file, and I chose to make the Include conditional on an externally-set "DoDeployment" property. Additionally each project defines the DeploymentServerGroup property so that the destination server(s) are properly filtered depending on what kind of project it is.
As you can see towards the bottom I'm simply executing the command file with the server list, pretty simple.
<!--
This targets file allows a project to deploy its package
As it is used by all project typesconditionally included from the project file
-->
<UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.BuildStep" AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.ProcessComponents.dll" />
<!-- Each Server needs the Group metadatum, either Webservers, Appservers, or Batch. -->
<Choose>
<When Condition="'$(Configuration)' == 'DEV'">
<ItemGroup>
<Servers Include="DevWebServer">
<Group>Webservers</Group>
</Servers>
<Servers Include="DevAppServer">
<Group>Appservers</Group>
</Servers>
</ItemGroup>
</When>
<When Condition="'$(Configuration)' == 'QA'">
<ItemGroup>
<Servers Include="QAWebServer1">
<Group>Webservers</Group>
</Servers>
<Servers Include="QAWebServer2">
<Group>Webservers</Group>
</Servers>
<Servers Include="QAAppServer1">
<Group>Appservers</Group>
</Servers>
<Servers Include="QAAppServer2">
<Group>Appservers</Group>
</Servers>
</ItemGroup>
</When>
</Choose>
<!-- DoDeploy can be set in the build defintion -->
<Target Name="StartDeployment" AfterTargets="Package">
<PropertyGroup>
<!-- The _PublishedWebsites area -->
<PackageLocation>$(WebProjectOutputDir)_Package</PackageLocation>
<!-- Override for local testing -->
<PackageLocation Condition="$(WebProjectOutputDirInsideProject)">$(IntermediateOutputPath)Package\</PackageLocation>
</PropertyGroup>
<Message Text="Tier servers are #(Servers)" />
<!-- A filtered list of the servers. DeploymentServerGroup is defined in each project that does deployment -->
<ItemGroup>
<DestinationServers Include="#(Servers)" Condition="'%(Servers.Group)' == '$(DeploymentServerGroup)'" />
</ItemGroup>
<Message Text="Dest servers are #(DestinationServers)" />
</Target>
<!-- Only perform the deployment if any servers fit the filters -->
<Target Name="PerformDeployment" AfterTargets="StartDeployment" Condition="'#(DestinationServers)' != ''">
<Message Text="Deploying $(AssemblyName) to #(DestinationServers)" />
<!-- Fancy build steps so that they better appear in the build explorer -->
<BuildStep
TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
BuildUri="$(BuildUri)"
Message="Deploying $(AssemblyName) to #(DestinationServers)...">
<Output TaskParameter="Id" PropertyName="StepId" />
</BuildStep>
<!-- The deployment command will be run for each item in the DestinationServers collection. -->
<Exec Command="$(AssemblyName).deploy.cmd /Y /M:%(DestinationServers.Identity)" WorkingDirectory="$(PackageLocation)" />
<BuildStep
TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
BuildUri="$(BuildUri)"
Id="$(StepId)"
Status="Succeeded"
Message="Deployed $(AssemblyName) to #(DestinationServers)"/>
<OnError ExecuteTargets="MarkDeployStepAsFailed" />
</Target>
<Target Name="MarkDeployStepAsFailed">
<BuildStep
TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
BuildUri="$(BuildUri)"
Id="$(StepId)"
Status="Failed" />
</Target>
I am the author of the other similar post. I have yet to find a solution. I believe it is going to be modifying the workflow to add a postprocessing MSBUILD -sync task. That seems to be the most elegant, but was still hoping to find something a bit less intrusive.
I'm not sure if that could help you with TFS 2010, but I have a blog post for TFS 2012: Multiple web projects deployment from TFS 2012 to NLB enabled environment.