Modify TeamCity build parameters programmatically - maven

I created some system properties in TC build configuration.
The value of these properties are passed to a maven configuration this way:
clean test -Dargument1=%system.property1% -Dargument2=%system.property2%
And this works as expected.
What I want to do now is to modify the value of the system properties when the build finish, so the next build will get these values.
Is it possible to do that programmatically, through Java or using Maven?
Is this the correct approach?

You can define build properties for this. Once your build finishes, you can craft a Maven plugin that sends a post request to TeamCity and alters the values for these build properties for the build type.

If I where you, I would craft maven task, which will update your properties via TeamCity restAPI on build completion.
It looks like mostly elegant way to do this task.
Full explanation for restAPI plugin could be found here:
http://confluence.jetbrains.com/display/TW/REST+API+Plugin
What is needed for your use-case is described here:
Build Configuration And Template Settings
Build configuration parameters: GET/DELETE/PUT http://*teamcity_url_goes_here*/httpAuth/app/rest/buildTypes//parameters/ (accepts/produces text/plain)
You could craft a request to update your parameters.
One more interesting thing: If you want to execute requests to REST API inside a TeamCity build running on the same server, you can use %teamcity.serverUrl% predefined parameter to construct URL

Related

Bamboo task to update properties file before maven build

I am using spring-boot and would like to update the application.properties file in the /src/main/resources folder as a task within a manual build plan. As the service can be installed on premise at the customer, I want to build the jar for each customer, where I can provide variables (e.g. spring.data.mongodb.* properties) to be injected/overridden before the maven build.
I found the inject plugin, but this adds a prefix before the variables, which in this case wont work as the DB connection is done automatically with spring.
Is there another plugin I didn't find which could do the trick, or is there an easy way to script something like this (please provide an example as I am not very familiar with shell scripts)?

How to access Java plugin from Gradle `ProjectConnection`?

I'm trying to get to the source sets. IIUC from How to get the project Extensions in gradle tooling?, there's no API that allows such access but I'm hoping I've missed something.
See sample code at: https://github.com/foragerr/tooling-api-custom-model
I extended the example at http://gradle.org/feature-spotlight-gradle-tooling-api/ , adding a new function to custom model to expose java.main.srcDir.
run ./gradlew invocation:run to demonstrate.
http://gradle.org/feature-spotlight-gradle-tooling-api/ shows how to create a Model that can expose a plugin's internals. https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/groovy/org/gradle/api/plugins/JavaPlugin.java shows that the Java plugin doesn't implement such a model. Therefore, getting to the source sets via ProjectConnection isn't possible.

Maven site:deploy (with DIFFERENT url) during "deploy" goal (when in testing profile)?

How can I make maven do a site:site and a site:deploy when the deploy is run?
Am I best off to make my own plugin (modified version of maven-release-plugin) or is there an easy way in Maven (configuration of a plugin within a profile)?
Thanks!
EDIT for clarification: I basically want a site-deploy done (to a special url) for snapshot releases. Namely the javadoc. Thanks!
Create two profiles.
The first will be active unless a property has been defined. It will use one URL.
The second one will be triggered by some property.
In each profile define the required settings for the site plugin with their respective differences.

maven cargo integration test - how to get cargo.hostname or profile?

I'm using Maven 2 w/ cargo to deploy to different remote tomcats depending on the maven profile used.
I also have integration tests (junit w/ remote webservice calls) that I would like to automatically run.
Question: How do I setup my test code to be able to read either the cargo.hostname (preferred, changed property value based on maven profile) or the maven profile actived so it knows which url to go run the tests against?
Specifically, this is in java in the test case.
Thanks!
Either you define a fixed value for the cargo.hostname (not the best; but sometimes it workds well, cause using a fixed test server) or better define an appropriate property in Maven for it and put the information also into a properties file which will be filtered by the build process in the src/test/resources folder which can be read before the real integration tests.

Passing parameters to a downstream maven job?

With the Jenkins plugin "Parameterized Trigger Plugin" you can pass job parameters to a downstream job. You have to specify the downstream job which I don't know in my case.
In am using all maven jobs with the setting "Build whenever a SNAPSHOT dependency is built" enabled such that the downstream jobs are automatically detected and run by Jenkins it self.
A such, I don't know the downstream job such that I can't specify it when using the "Parameterized Trigger Plugin".
How can I pass all parameters value's to all the detected jenkins maven jobs?
Sorry, but I have to disappoint you. There is no way to add parameters to the Build whenever a SNAPSHOT dependency is built. There is a little manual work to do to "add this functionality":
Go to the triggered Job with parameter
Go to each Upstream-Job and add a post build action: Trigger parameterized build on other projects
Its not the ideal solution. But the plugin doesn't support this use case.

Resources