Flattening TeamCity artefacts folder structure - teamcity

I have a TeamCity (9.0.2) build configuration which contains the following artefact path pattern:
App\Agent\**\bin\%env.Configuration%\** => Deployment\AgentBuildPackage.%env.ApplicationVersion.EMX%.%system.build.number%.zip
which will create a file named something like AgentBuildPackage.4.5.0.185.zip in an artefact folder named Deployment
The current structure is like this:
Deployment/
AgentBuildPackage.4.5.0.185.zip/
MyFirstServiceFolder/
bin/
Debug|Release/
All the Files
The artefact archive contains all the folders it finds under App\Agent which is great. What I can't figure out is how to flatten those individual folders so they no longer contain the /bin/Release sub-folders.
What I want is
Deployment/
AgentBuildPackage.4.5.0.185.zip/
MyFirstServiceFolder/
All the Files
Can anyone tell me how please?

You can specify target folders within your target archive by using the ! character after the name of the .zip file. Like this:
folderA\** => output.zip!/afolder/
Depending on how many service folders you have, this could be quite verbose, as you'll need to do it for each one, but it should do what you've described:
App\Agent\MyFirstServiceFolder\bin\%env.Configuration%\** => Deployment\AgentBuildPackage.%env.ApplicationVersion.EMX%.%system.build.number%.zip!/MyFirstServiceFolder/
Here's the documentation page on specifying artifact paths if you haven't seen it yet: https://confluence.jetbrains.com/display/TCD9/Configuring+General+Settings#ConfiguringGeneralSettings-PathsPatterns

Related

Copy to directory outside of project directory using Gradle 4.0.2

I have a gradle build which generates war file. I want to copy war file to my application servers' dropins directory which is somewhere outside of project directory. I have following copy task to do this.
task copyWarToDropins(type: Copy,dependsOn:[war]) {
from './build/libs/bds-service-token-1.0-SNAPSHOT.war'
into file('/apps/dropins') // want to copy to 'C:/apps/dropins' directory
rename { fileName -> 'bds-service-token.war' }
}
build.dependsOn copyWarToDropin
It evaluates /apps/dropins relative project directory and does copy there. I have tried many ways I can think of but could not make it copy to C:/apps/dropins directory.
Can someone please help?
First, please note that using into file(...) is redundant, as each call to into(...) will be evaluated via Project.file(...) anyhow.
As you can read in the documentation , file(...) handles strings in the following way:
A CharSequence, including String or GString. Interpreted relative to the project directory. A string that starts with file: is treated as a file URL.
So, one way to solve your problem could be using an absolute file URL.
However, if you continue to read the documentation, you will see that Java File objects are supported. So you could simply create such an object:
into new File('C:/your/absolute/path')

Get File Names in Resource directory

I have a Xamarin.Forms GetFiles.IOS project that has a "Resources" directory that's part of the project. I have placed 25 files into the Resources Directory. I now want to be able to go to the resource directory and get all the file names. I created some code to read the files in the directory but I'm getting a DirectoryNotFoundException. Here's the code I'm using.
String dir = Directory.GetCurrentDirectory();
var filePath = Path.Combine(dir,"Resources");
String[] files = Directory.GetFiles(filePath);
I just can't seem to get the path correct!
Thank you for helping me.
There are two things necessary to have the files be copied into the app folder:
They need to be set with Build Action Content with Copy to Output Directory Copy Always in the Properties window.
They must be in a different custom folder than Resources.
Number 2. is because Resources is a special reserved directory name and even if you put some content files in it, it is never copied in the app bundle's folder. You can check for yourself, if you put the files in a folder Test, your code will work as intended.

Replace artifacts paths in TeamCity

I have a multi-module maven project that is built by teamcity. This is working and the resulting artifacts are:
/core/target/core-system-1.2.3.war
/plugins/plugin-a/target/plugin-a-1.2.3.jar
/plugins/plugin-b/target/plugin-b-1.2.3.jar
/plugins/plugin-c/target/plugin-c-1.2.3.jar
/plugins/...
Currently, the artifacts are collected using this under general settings:
core/**/target/*.war => dist/core
plugins/**/target/*.jar => dist/plugins
So, I have all needed files in the dist-folder (afterwards they are pushed to a deployment-server via ssh). However, teamcity keeps the "target"-folder (which is also mentioned here [1]):
/dist/core/target/core-system-1.2.3.war
/dist/plugins/plugin-a/target/plugin-a-1.2.3.jar
/dist/plugins/plugin-b/target/plugin-b-1.2.3.jar
/dist/plugins/plugin-c/target/plugin-c-1.2.3.jar
What I need is to remove the target directory from the results:
/dist/core/core-system-1.2.3.war
/dist/plugins/plugin-a/plugin-a-1.2.3.jar
/dist/plugins/plugin-b/plugin-b-1.2.3.jar
/dist/plugins/plugin-c/plugin-c-1.2.3.jar
There are a lot of plugins and they change from time to time, so I don't want define them all with static paths. Therefore, using plugins/plugin-a/target/*.jar => dist/plugins/plugin-a is possible, but not feasible.
So, how can I remove the target directory from the artifact path, without selecting other jars that are not within the target directory?
[1] https://confluence.jetbrains.com/display/TCD10/Configuring+General+Settings#ConfiguringGeneralSettings-artifactPaths
TeamCity is 10.0.4
Have you tried something like this:
core/**/target*/*.war => dist/core
plugins/**/target*/*.jar => dist/plugins
According to TeamCity docs you referenced it's:
[..] That is, TeamCity will create directories starting from the first occurrence of the wildcard in the pattern.

In an Android gradle build, how I can I make it consider a task not UP-TO-DATE when the output directory is not exactly the same?

I'm using gradle for an Android project.
I have a task that downloads some files to put them into the build (as Android assets).
I would like to have a task download some files from the web and put them into a temp directory, from where they are copied (by a separate copy task) into the assets directory during the build.
I would like to make sure that the downloader task will rerun ( and not be considered UP-TO-DATE ) if the output directory changed in any way ( e.g. files changed or missing, directories missing, files in subdirectory missing etc, recursively. ). Currently, I specified the output directory as #OutputDirectory, but it seems to not do what I want:
class AssetDownloaderTask extends DefaultTask {
#OutputDirectory
def File outputDir
#Input
def String databaseChecksum
....
E.g. if I delete a file from one of the subdirectories, gradle still considers the task UP-TO-DATE. Isn't gradle supposed to store a hash of the outputs?
How can I achieve what I want?
I'm not a Gradle expert by any means, but I believe you want to use the #InputDirectory annotation instead.
This will cause the task to be considered out-of-date when the directory location or contents have changed.
https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/InputDirectory.html
EDIT: Wow, didn't notice this was so old. Sorry if necroing is bad SA etiquette.

How do Teamcity artifact paths work?

Can anyone give me an example of what the Artifact paths setting defined for a build configuration could look like if I want to create two artifacts dist and source where I am using the sln 2008 build runner and building my projects using the default bin/Release?
**/Source/Code/MyProject/bin/Release/*.* => dist
**/*.* => source
I get two artifact roots dist and source but under dist I get the whole directory structure (Source/Code/MyProject/bin/Release) which I don't want and under source I get the whole thing along with obj and bin/Release which I do not want.
Can you give some advice on how to do this correctly?
Do I need to change the target location for all the projects I am building to be able to get this thing to work?
So you'll just need:
Source\Code\MyProject\bin\Release\* => dist
Source\**\* => source
This will put all the files in release into a artifact folder called dist and everything in Source into a artifact folder called source.
If you have subfolders in Release try:
Source\Code\MyProject\bin\Release\**\* => dist
According to TeamCity documentation; it should be like this:
file_name|directory_name|Ant-like wildcard [ => target_directory ]
So..
Source\Code\MyProject\bin\Release|**\* => dist (| not \)

Resources