How do Teamcity artifact paths work? - visual-studio

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 \)

Related

How to create a Zip file using gradle 2.3

I have my archive at location myProject/unzip and need to:
Zip the contents within the unzip folder and create a zip file with some name at any location within the project.
Using gradle 2.3.
Can anyone help me for this?
I am not sure what you are doing differently than the examples in the documentation from the link I gave in the comments. But this works for me with Gradle 2.3:
task myZip(type: Zip){
from "$projectDir/unzip"
archiveName = "my-zip.zip"
destinationDir = buildDir
}
The input folder is called unzip and needs to present as a child in the project folder. It outputs a file my-zip.zip in the build folder.
Be sure that there actually are some resources located in the from path, or Gradle might skip it.

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.

Create zip of the source code in gradle

I want to create a zip of my entire code base using a gradle task. I am facing one issue to get the parentDir . I have tried using project , project.rootDir, project.rootProject, projectDir, project, sourceSets*.allSource . I am not getting any correct output. I f I use project alone, it gives me a zip containing only the subproject files. Any pointers?
My task looks like this :
task srcZip(type:Zip){
from project
exclude('**/*//*.iml', '*//*build/', '*//*dist')
exclude('*.zip')
destinationDir file('dist')
}
I build my source code zip from the root with a list of projects like so:
from ('./') {
include ([':proja',':projb',...].collect {
relativePath(project(it).projectDir) + '/'
})
}
It lets me select a sub-set of projects to archive. Don't forget to filter out some temp dirs like build/ and .gradle/.
relativePath(project.rootDir) or relativePath(rootProject.projectDir) should give you access to the top of your multi-project repo.
If you put the task in your root project build.gradle, you can do the following:
task srcZip(type: Zip) {
subprojects.each { project ->
from project.sourceSets.main.allSource
}
exclude('**/*//*.iml', '*//*build/', '*//*dist')
exclude('*.zip')
destinationDir file("dist")
baseName = "sourcecode"
}
This code assumes a few things:
1) All of your subprojects have source sets. If this is not the case, you will have to add a check.
2) There is no source code in the root project. If there is, and you wish to add it, you can add the following line:
from project.sourceSets.main.allSource
project.parent.projectDir worked for me . Initially when I used it, the task wouldn't stop and keep executing without giving any results but I tried in another system, it worked. Thanks for all the reponses but I think this is the perfect solution for me.

Flattening TeamCity artefacts folder structure

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

SCons: directory dependency in a parallel build

I'm having trouble with a directory dependency in a parallel build in SCons.
Consider two projects with a single SConstruct in the following (simplified) hierarchy:
- SConstruct
- project1
- src
- project2
- src
- build
- project1
- project2
- dist
- project1
- project2
Each of project1 and project2 are supposed to be built under the relevant build directory (using variant dir) and several targets needs to be installed under the relevant dist directory.
Project 2 depends on Project 1's dist. I've states this dependency explicitly using the Depends() statement like so:
Depends('project2', 'dist/project1')
When I use a non-parallel build, there's no problem. Project 1 is fully built, targets are installed in the dist directory, and only then project 2 is built. However, when I use multiple jobs (4), project 2 is being built simultaneously to the Install() builder being run for the files needed to be installed in project 1's dist directory.
So, my questions are:
Does the Depends(project2, dist/project1) statement refers to the creation of the dist/project1 directory or to the completion of building all the directory's children?
How should I solve this issue?
Thank you very much,
BugoK.
Instead of specifying the actual directories as strings in the Depends() function, try specifying the actual targets as returned by the SCons project1 and project2 builders. Every SCons builder (or at least most of them) returns the affected target as an object, and its better to use this object instead of the file/directoy name since if you dont use the exact same file/directory path, it wont be considered as the same target.
Here is an example, fill in content accordingly:
project2Target = Install()
# Im not sure how you're building project1, so replace the builder
project1Target = Proj1DistBuiler()
Depends(project2Target, project1Target)

Resources