Teamcity deployment to another server via ssh - plugins

I'm trying to use teamcity deployer plugin to send my build result (war file) via ssh to another computer in network.
my problem is how to config deployer to find my builded war file.
I used %teamcity.build.workingDir%**/*.war in Artifacts path setting but it can not find any file in there.
The log show that it try to find my file in here /home/teamcity/TeamCity/buildAgent/work/c4bca27d2b00a6fe**/*.war.
the path is correct but It's not working...
the teamcity document for Accessing Build Artifacts is not clear, and does not show what should i use in setting dialog.
Update:
I tried to use **/mywar-1.0.war and **/build/libs/mywar-1.0.war, both works but now the problem is, it deploy the file with it's subdirectories like this dest/build/libs/mywar-1.0.war
but i need dest/mywar-1.0.war,
so still don't know how to configure it...

Teamcity deployer plugin, uses pattern as a Artifacts path to find files for deploy, in most cases as #Vlad said using **/*.fileType or **/filename.type is enough,
for example : **/*.war or **/myprojectfile.war
but sometimes your output files are in subdirectory tree, so using pattern case the deployer to create those subdirectories on destination.
in this case, I just need the war file without its subdirectory so the right way is using complete path to that file.
for example :
my war file is in build/libs/ folder after build process
so using build/libs/mywar.war as a Artifacts path, will deploy the war to destination without its subdirectory.

Artifacts resolved under checkout directory as documentation says, so just **/*.war is enough.

Related

Content files are not deployed in the Service Fabric package

We want to deploy a couple of static content files in the service fabric package (configs, metadata). As long as those files are in the root of the package, everything works fine. If we however put them in a subfolder, the files are not included in the package. Is this some kind of bug, is this by design or do we need to configure something?
Update
It seems that the problem is in our own custom deployment code (we package and deploy to service fabric ourselves). This is indeed working, as long as the files are marked with Copy to Output Directory.
Make sure that you've updated the project metadata for any such content files so that the "Copy to Output Directory" property is set to "Copy Always" or "Copy if newer". If the file doesn't show up in the service project's bin folder after executing a normal build, then it for sure won't end up in the generated package.

adding my own jar file as javaagent on bluemix

I want to make a custom buildpack on bluemix, as part of it I am trying to add my own jar file as a javaagent. I used to work with Tomcat where I just added the extra agent to the catalina.sh script.
On bluemix those are the steps I took:
I create new project and uploaded my code.
I cloned the default java buildpack to my own git repository.
On the repository I added the .jar file on /lib/java_buildpack folder.
Now is the step I have trouble with, I located the:
java_opts.add_javaagent(#droplet.sandbox + 'javaagent.jar')
function call which according to the comments should so exactly what I am looking for.
the issue is that when I check the function I see that it calls the following function:
qualify_path(path, root = #droplet_root)
"$PWD/#{path.relative_path_from(root)}"
I cant figure out where is this #droplet_root position is, if I could find it I could upload my jar file there.
I tried adding the relative position like this:
java_opts << "java_buildpack/myAgent.jar"
But it didnt work.
Any suggestions on how it might be achieved? where should I place the file or is there any other way?
Forking the buildpack is one way to achieve this. You can implement this as a "framework" in the Java buildpack. Here are a few samples you can refer to which also adds an agent jar:
https://github.com/cloudfoundry/java-buildpack/blob/master/lib/java_buildpack/framework/new_relic_agent.rb
https://github.com/cloudfoundry/java-buildpack/blob/master/lib/java_buildpack/framework/jrebel_agent.rb
Another little hacky way is to simply add the agent jar to your application package, and then add a Java option to enable the agent, using the JAVA_OPTS environment variable. That requires you to find out the path where the agent jar ends up in the running application container. You can browse to it by using "cf files". This will have a dependency on the internal structure of the droplet so it may get broken if the buildpack changes the droplet structure.

xcopy a maven .m2\repository\* folder to another computer?

I'm using eclipse 3.7 and my local maven repository has a bunch of jars in it. I tried to build the project on another computer that is on a different network and has *.jar download restrictions. I will not be able to get the restrictions lifted. Here is an example error:
e.g. Access denied to http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/2.3.2/maven-compiler-plugin-2.3.2.jar Error code 403, Forbidden (Content blocked ...)
It would be very nice if I could simply copy my .m2\repository\ folder into the .m2\repository\ on the other computer--both are running windows. I really don't want to manually install 100s of jars on the other computer.
Is xcopy for .m2\repository\ supported?
Yes, you can copy the .m2/repository folder to any other location/storage device you want.
Maven only needs to know the path to the local repository (by default it's in %USER_HOME%/.m2/repository). You can change that path in Maven's settings.xml (see settings reference) if you decide to keep the artifacts in a different location.

How do we copy an entire directory to another directory in maven?

I would like to improve the build foe development in our project and in this regard I would like to achive the following using maven:
I want to copy an entire directory heirarchy, including the directory itself to another directory using maven. How do I achive that ?
I need this to copy a "MyApp.ear" directory to \domain\autodeploy.
Then, I would like to create a file "REDEPLOY" under autodeploy of weblogic domain using maven
When ever we do some changes to java file, would like to copy only the exploded dir of class files and touch the REDEPLOY filr using maven to trigger the auto-deploy
Pls. suggest how do we achive this using maven.
A couple suggestions come to mind:
The maven antrun plugin will let you copy files, folders, etc
The maven deploy plugin allows for uploading with ftp & ssh - and so does the antrun plugin

Deploy war file with modifiable properties files

I am building a web service and am packaging it into a war file for deployment. Right now all of my config files (.properties and .xml) are being packaged into my .war file. This isn't going to work as some of these files will need to be modified for each individual installation. I know that some servlet containers will leave the .war files intact which would mean the config files would never be easily modified. My question is this: what is the best practice for deploying a .war file with these external config files? I'm thinking that the config files will need to be shipped separate from the .war file and placed into a directory that is in the classpath. Is there a default directory setup like this in Tomcat that these files can just be dropped into and my web service will be able to find without much trouble?
Maybe I shouldn't be using a war file for this setup? Maybe I should just be providing a zip file (with the same contents as the war file) and the deployment will simply be to extract the zip into the webapps directory?
I do not know any default directory in Tomcat to store configuration, my
attempts to solve the same issue have been :
1 - Move configuration to the DB and provide scripts or webpages to modify values.
2 - Have a script to deploy the war. The script would merge configuration from a user directory into web.xml or other deployed config files.
3 - Have webapps look first in a user directory for configuration and
if not found then look for configuration files deployed by the war.
Least favorite is 3 - it require all webapps to check two places for configuration and
you end up with two different xml files on the server with different values and it is not always clear which one is used.
Next favorite is 2 - the webapps can be written without knowledge of multiple config files, but you run into issue when someone does a deploy from Tomcat manager instead of using your script.
Favorite is 1. This just works in most cases. Problem is when you don't have a DB or
want to configure how you connect to the DB.
If having the file visible from all webapps is not an issue, you could put it $CATALINA_HOME/lib.
One solution is to modify property file after deployment of war file is to use ServletContext.getRealpath() method to get the real path means path of file in the server where it is deployed and then modify that file it will modify file in container only not the original file. So you need to backup it if it is important modification for you. So by this you do not need to redeploy war file as it is already modifying file from deployed container.
This solution can edit a file that is in webpages folder also from the java class.
If you want more description or how to do it then let me know i have did it.