Is it possible to create a Review App dynamically? - heroku

On Heroku pipelines, there's a option to create the pipeline automatically or when the PR is created (clicking on the button). But looks like that there's no option to trigger that by the terminal, after running the tests or doing some modification.
The is a monorepo of multiple projects based on a env variable (like this example).
Currently to build a specific application we have to hardcode the app.json, but it's not possible to add a second pipeline with differents variables, or even dynamically build (based on a tag or whatever) without hardcoding

Related

Share Git repository directory across multiple build definitions

When a private agent build starts in VSTS, it gets assigned a directory, e.g. C:\vstsagent_work\1\s
Is there a way to set this to a different path? On other CI servers, like Jenkins, I can define a custom workspace for a job. I'm dealing with a huge monorepo and have dozens of build definitions around the same repository. It makes sense (to me anyway) to share a single directory on the build agent computer.
The benefit to me is that my builds can use pre-built components from upstream repositories, if they have already been built.
Thanks for any help
VSTS build always creates a working directory per build definition. This leaves you two options:
Create a single build definition and use conditionals on steps to skip certain steps in order to only run what is needed. This allows you to use the standard steps and may require a powershell script to figure out which steps to run and which ones to skip. Set variables from powershell using the special logging commands.
Disable the get sources step and add a step that manually fetches sources. You'll need to clean the working directory, checkout the right commit, basically replicating the actions in the get sources step manually. It may require some fidgeting to get all the behavior correctly for normal build, pull request builds etc. That way you can take full control over the location where sources are checked out.
I'd also recommend you investigate the 2017 project formats that use the new <packageReference> in the project files to fetch packages. The new system supports configuring a version range which can always fetch the latest available version of packages. It's a better long-term solution.
No, it isn’t available in VSTS build system.
You can change working directory of agent (C:\vstsagent_work) (Re-configure it and specify another working folder), but it won’t uses the same source folder for different build definitions, the folder would be 1, 2, 3 ….

Setting variables defined in a POM dynamically with Maven

I'm working on a task to dynamically build an 'About' (static HTML) page for my application and would like to use the build number for the project from TeamCity to set it. We want a different version generated and deployed with each deployment. This leads me to want to store values to variables used in my build.
So my challenge as I see it is:
How do I allocate a value to a variable dynamically during a Maven build
phase and then have that available for further parts of the build
(e.g. generating a file).
The background of what I'm trying to do is as follows (with the current variable problem highlighted):
Get value from Team City Build Server via REST call
Allocate value to Maven variable
Use variable during file generation
Profit
However it seems most links refer to obtaining values from properties files, not setting them up dynamically during build execution.
Lastly - I figure I'll do a bit of this with the Ant-Run plugin
If you use ${buildNumber} in a processed resource, maven will automatically pick up the build number from team city and replace the variable with the appropriate value (without using REST or any other complicated technique). Obviously, this won't happen in local builds, but my team doesn't have a problem with that. It would be easy to fix this using a build profile that assigns some value to the variable when the build is in your local environment rather than in team city.
We also use %build.vcs.number% as the build number format to force team city to use the svn build number, rather than its own arbitrary build number.

Teamcity build for live after successful CI build?

I have an environmental build system which currently has the following environments:
dev
ci
uat
live
Just to be clear when I say environmental build I mean there are a set of properties files for each environment and during the build these properties are used to template project files, so a database server may be "localhost" on dev environment but "12.34.56.78" on CI. So when starting the build you can give it an environment property and it will build for something other than dev (which is the default environment).
Now the CI build works fine and spits out the artifacts correctly, however as the build is CI all of it is configured to work on that environment, and I am looking at being able to trigger a build for live or uat when a CI build succeeds. This would then run the same build but with a different build argument.
Now I noticed there are a few mechanisms for this, one seems to be doing an automatic trigger on complete which could trigger another build, but this seems to require 2 separate build configurations which are essentially identical other than the build argument being "environment=live" rather than "environment=ci". Then there is adding another build step which would be the same as the first but take different argument and output the live artifacts elsewhere, but this would always happen much like the first option.
The final option I could see was to trigger a manual build once I have a live candidate, but it is unclear as to how to set a build argument, I could make a build parameter however it doesn't seem to get pulled into the build script like a command like build argument would.
I will see if there is a better answer, but after writing this I found that using Build Parameters seems the best option, this then can be embedded within your build configuration anywhere using the %environment% (or %your_parameter_here%).
This can then be setup to create a form element for manual builds so you can easily create a build for a different environments.

Using global properties or build steps in TeamCity

I have a lot of projects in my TeamCity server, for building and testing multiple sites. We use Selenium RC to test the sites every night, and I would like to reuse one step or configuration instead of having copies in each project.
I have looked into using Templates, but they only seem to be accessible from the project it is defined in. The same goes for properties, as I tried to put paths and some shared values in system or environment properties and using copied build steps using those shared properties.
But it all fails, as none of these methods seem to be usable across projects. How do you solve this type of issue? It must be possible somehow, right?
As per my comments for your question you can use a single template configuration build across multiple Projects.
See TeamCity documention for information on how to do this.
TeamCity has a new feature (as of 8.0) that supports global configs/parameters/env variables. 8.0 supports the new concept of project organization/nesting, and as part of that feature set all projects now inhert from the "Root" project. And on that root project you can specify a number of things, including parameters, etc. This does not appear to support build steps.
They documented the change in http://youtrack.jetbrains.com/issue/TW-11202.
--
You could achieve a "global property" by creating a dummy build configuration which has your shared properties then for all your builds which need access to the global properties you create a build dependency. When your real build configuration is called it will first call the dependent build configuration (which does nothing meaningful) then it passes the properties from the dependent config (with a dep.bt prefix instead of just the system prefix).
Depending on the logic you need in a shared build step you may be able to actually perform real logic in the dependent build (it won't be able to inherit any properties or VCS details from the "real" build).
Since this is a bit outdated, and the answers above aren't completely clear, thought I would post how I did this with TeamCity 8+.
Basically, a template can be used within the project and its children. If you move a template to the parent, it becomes available to all the siblings of the original project.
Go to the template.
Click the "Move" button (bottom-right pane).
Select a parent (or root).
Note: If the template is attached to a VCS root that is bound to the current project, you'll first have to move the VCS root to the same level to which you're trying to move the template.

How do I run a TeamCity build as a specific user

I have a build configuration which deploys my code to a machine. Depending on which machine I am deploying to (e.g. dev/uat/prod), I need to run as a different user.
Rather than hardcoding the username and password in the build files (not really possible as they change regularly for security reasons) I would like to be able to type them in at the point I run the build. I would envisage the "Run Custom Build" in TeamCity would have this option but I can't see anywhere to input that information.
Is there any way to do this (short of remoting into the build agent and changing the user which the build agent runs as)?
Thanks
The RunAs plugin combined with TeamCity 7's new Typed Parameters will let you make the password a "typed" parameter plugin.
Then, when it's entered at the Run screen, it will not be visible in the build history.
EDIT: Much later, as covered in the comments: You probably don't want to do this. Consider having separate pools which run as different users, and parameters to specify what builds are supported by what pools.
Neil, you can pass build parameters via Run Custom Build dialog.
There are "System properties" and "Environment variables" sections, where you can add new build parameters or redefine existing ones.
Please read more: http://confluence.jetbrains.net/display/TCD6/Triggering+a+Custom+Build

Resources