I am using the 3 build configurations to use VCS root as develop, staging and master. Each having custom parameters like build env, Kubernetes cluster, namespaces, etc.
However, sometimes my dev team needs to check if the master branch code is running correctly on dev env, dev K8s cluster, dev namespaces.
For that, I want to create the custom prompt-based parameters where they can choose the VCS Root with parameter options like develop, master or staging.
Can anyone please guide how to achieve this for the single build configuration? Can I parameterize the VCS root? I want to keep this prompt-based option so there will not be any automatic trigger required.
I will keep the the common 3 build configurations as it is. I just want to add 4th build configuration named as "Custom" where there will be choice for every parameter.
Yes, you can parameterize your VCS root,
if your repository is same for all environments then you have to set only one parameter for VCS root an that is for branch name.
Step 1 :
Write %branch-name% in VCS root configuration and save it.
The same parameter (config.branch-name) will be added automatically in your build configuration in which this VCS root used (new configuration as well as in existing configuration)
Step 2 :
In other configuration keep your config.branch-name parameter as it is ( Type : Configuration parameter, Display:Normal) but,
in new configuration, set Display : prompt for config.branch-name parameter
Note : This is only for setting variable based VCS root, assuming you can set all other parameters as per your requirement
Related
I have a VCS Root's client mapping set up on the root level like this:
VCS root name: My Main
VCS root ID: Main
client mapping: //Main/... //team-city-agent/...
Main contains the source of multiple projects so its structure looks like:
Main/Project1
Main/Project2
...
Then in my build definition for Project1 I have a VCS trigger set up with a rule like:
+:root=Main:/source/Project1/**
I can see build kick off whenever I check in something under Main/Project1. However the problem is whenever there are changes checked in under Project2, I see the Pending Changes number incremented on the admin page for Project 1. This is very annoying and I wonder if my setup is correct.
Is there any way to not show the pending changes in Project2? Do I have the VCS Root set up correctly?
I can't speak for Perforce directly, but I would suggest you're seeing the pending changes for all projects because it's the VCS root (and checkout rules) that detect changes and it's looking at the full source; your VCS trigger is simply limiting the build running to a specific subset of that.
You can try specifying a checkout rule on the VCS root :
+:/source/Project1 => .
I've used this to achieve similar results where I need 2 builds running in isolation across 2 solutions under the same VCS.
I am running TeamCity 9x and it seems that it does not support a VCS password parameter, meaning I have to either use SSH keys (proving difficult, but that's a separate issue) or enter the password for every build config which is unacceptable as we will eventually have well over 100 build config so changing the password would be too arduous.
Is there a way that I can specify the password once and inject that into each VCS root?
Kind of workaround solution, but still.
You could try parameterizing other VCS Root details instead!
Create one VCS root, provide username/password for it, parametrize whatever you want with standard Teamcity parameters. Then there are few possible ways of using parameters:
Provide parameters for every build as default values;
Ask for parameter value on build run (for manual builds);
Provide several build templates with parameters preset.
For example, on my current project we are using Git VCS Root with branch name parametrized. All builds with this VCS root are either have branch name set in their default parameters or use value provided from run menu.
We have multiple layers of our products split into different build configurations for continuous integration. For the sake of this question, let's just say we have a "Front-End CI" build, and a "API CI" build. The VCS roots are configured to pull in all branches, and triggered to run upon checkin, as should be expected for CI.
Now I have my User Acceptance project, where I use CloudFormation to dynamically spin up servers to which I deploy. I have snapshot dependencies set up for the CI builds mentioned above, and everything works as expected for the default branches on each of the VCS roots and dependencies. I expect that a feature branch for the front-end may not necessarily necessitate a branch from the default for the API, and the current way I have it setup accounts for that as well.
That's where I begin to have issues. If I have to branch both the front-end and API, I cannot get TeamCity to do what I want in this regard. My question is this: how do I tell Team City to run a UA build using branch "A" from the Front-End CI build config and branch "B" from the API CI build config, where "A" and "B" can be any arbitrary branch? Currently right now, all branches from both snapshots are shown when I look at the UA build config. Here's a good picture:
If I run api-branch, it will always use the default branch from the Front-end CI snapshot. Same for any branch on the front-end snapshot. I cannot seem to find a way to specify this in the configuration or when starting a build.
I'm up for just about anything to address this, including build configs that are just cloned off of each other to specify branches the way they're meant to, but I'm just not seeing how I can do that either. Thanks!
Create a teamcity template target which monitors both the front end and API repositories and can trigger on changes. This should be one target (and not 2 different targets). Parameterize the branch names so that actual targets have to give the branch name
I would suggest creating a mapping of the frontend:api branches in a datastore( file,db,nosql) . Then dynamically create teamcity targets (through REST API) for each new/modified combination and explicitly set the branch names. Once the targets are created they will automatically run whenver there are any changes.
For testing purposes I sometimes copy some Jenkins jobs from a produtive instance into our testing instance.
Repositories, branches etc. are controlled by environment variables but I want to block the "Deploy artifacts to Maven repository" post build action for all jobs in this Jenkins instance.
Any idea how to do this?
There is a Jenkins plugin for conditional build steps: Conditional Build Step Plugin. While plugin supports a variety of condition types, for reference here simple use of toggling deployment via global Jenkins property used in a boolean condition.
Property can be defined as Global Property in Jenkins configuration (Jenkins home > Manage > Configure: Global Properties)
As example lets say you have defined a property with name doMavenDeploy:
production environment: property value is true
test environment: property value is false
job configuration would need to be modified to add a Conditional build step with :
Run? : Boolean condition
Token : $doMavenDeploy
Step to run if condition is met : add maven deployment there.
In that way you would need to modify your jobs once, after modified configuration is active you can move them between both servers without impacts.
There are other alternatives possible depending on specifics and constraints in your projects:
introduce different maven profiles for 'normal' and test builds and control activation via environment variable, file present or similar
if you use artifactory/nexus or similar: configure test server without deployer credentials
We're testing Octopus Deploy 2.0 (OD) to deploy web services, windows services and citrix applications.
QUICK QUESTION:
When using config transformation, can parameters be used to indicate which config file should be used for the transformations?
MORE DETAIL:
When setting up for config transformations, we would like to have files named
MyApp.DEV_US.config
MyApp.DEV_CANADA.config
MyApp.DEV_AUSTRALIA.config
and so on for TEST, STAGE and PRODUCTION
Our deployments to DEV, for example, always include deployments to all regions. So we would prefer if OD environments were DEV, TEST, STAGE and PRODUCTION. Then in each deployment, we have multiple steps that deploy to each region.
However, OD config transformations only look for OD Environments when looking for which config files to use as part of the transformation. It seems OD would require us to bring each region up to the environment level, which from our POV is not ideal and would clutter the dashboard.
Can we pass parameters into the config transformation process such that we can indicate which file to use for the transform?
I believe you can achieve what you are after with the following, but it will require multiple steps in the process.
Create a step called Deploy to Dev - US and a step called Deploy to Dev - Canada
Now define a variable called CountrySpecificConfigFiles and you can scope it to the required step (and environment etc)
In the Configuration transformations section for each Steps, choose the variable defined in the step above
You could abstract this further by naming your steps DEV_US and DEV_CANADA and define just the one variable value as Web.#{Octopus.Task.Name}.config without any scope to steps, or by removing the variable and doing it inline in the Additional Transforms field.