Hudson Config for Mule (Cloudhub) - groovy

I am setting up a job in hudson to build maven based mule application on SVN , uploading to artifactory and then deploy it on cloudhub.
I am able to build project and upload it to artifactory but the problem is how to deploy it on cloudhub after that.
I have groovy post build plugin but not sure what script to write in it to proceed.
Is there anyone who could give me some pointers to proceed??
Thanks in advance

You should use mule-maven-plugin, it is the currently supported way to deploy to CloudHub via Maven. This a sample plugin configuration:
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-maven-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<deploymentType>cloudhub</deploymentType>
<muleVersion>3.7.0</muleVersion> <!-- This is the runtime version as it appears on the CloudHub interface -->
<username>myUsername</username>
<password>myPassword</password>
<environment>Production</environment>
</configuration>
<executions>
<execution>
<id>deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
And remember to add this to your settings.xml so Maven can find the plugin:
<pluginRepositories>
<pluginRepository>
<id>mule-public</id>
<url>https://repository.mulesoft.org/nexus/content/repositories/releases</url>
</pluginRepository>
</pluginRepositories>

You can use maven cloudhub-maven-plugin. Please refer details at cloudhub-maven-plugin
Hope this helps.

Related

Maven - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project XXX: Fatal error compiling

I have looked for other solutions in similiar threads, but they did not help me. I am working with IntelliJ and want to deploy an app on Azure. Before my trials to add the azure dependencies, it worked all fine.
The problem was I had the wrong configuration of jdk in the XML.
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<fork>true</fork>
<executable>C:\Program Files\Java\jdk-14.0.2\bin\javac.exe</executable>
<source>1.8</source>
<target>1.8</target>
<compilerArgument>-XDignore.symbol.file</compilerArgument>
</configuration>
</plugin>
Before it was the jdk-8.x.x_XXX, which was never installed on my machine.

How to set up JASMINE using MAVEN-PLUGIN?

I have a folder structure like
-root
-pom.xml
-service
-web
-pom.xml
-src
-main
-test
-java
-javascript
-lib
-specRunner.js
-runner.html
-spec
-model
-view
-collection
I have written JASMINE test cases in the "spec" folder containing "model","views","collections".
I'm able to see my test results in runner.html.
Now i'm trying to integrate with MAVEN build. SO followed steps given in http://searls.github.io/jasmine-maven-plugin
But i'm getting build failure when doing mvn clean install and unable to see anything on localhost:8234 when doing mvn jasmine:bdd
I'm unable to find out what went wrong. The errors in console show something about require js.
Following is my POM.xml for jasmine-maven plugin
<plugin>
<groupId>com.github.searls</groupId>
<artifactId>jasmine-maven-plugin</artifactId>
<version>1.3.1.5</version>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<jsSrcDir>${project.basedir}/src/main/webapp/js</jsSrcDir>
<jsTestSrcDir>${project.basedir}/src/test/javascript</jsTestSrcDir>
<specRunnerTemplate>REQUIRE_JS</specRunnerTemplate>
<preloadSources>
<source>${project.basedir}/src/main/webapp/js/libs/require.js</source>
</preloadSources>
</configuration>
</plugin>
Can anybody guide what is wrong or better provide some demo project (Backbone+Require+Jasmine) which is integrated with MAVEN build.
Thanks in Advance.
I read some blogs and tried editing my jasmine-maven plugin as follows
<plugin>
<groupId>com.github.searls</groupId>
<artifactId>jasmine-maven-plugin</artifactId>
<version>1.3.1.5</version>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
<configuration>
<debug>true</debug>
<specRunnerTemplate>REQUIRE_JS</specRunnerTemplate>
<sourceExcludes>
<exclude>lib/jasmine.js</exclude>
<exclude>lib/jasmine-html.js</exclude>
<!--<exclude>libs/text.js</exclude>-->
</sourceExcludes>
<preloadSources>
<source>${basedir}/src/main/webapp/js/libs/require.js</source>
<source>${basedir}/src/main/webapp/js/main.js</source>
</preloadSources>
<jsSrcDir>${basedir}/src/main/webapp/js</jsSrcDir>
<sourceIncludes>
<include>${basedir}/src/main/webapp/jslibs/*.js</include>
<!--<include>libs/jquery-1.9.1.js</include>
<include>libs/underscore-min.js</include>
<include>libs/backbone-min.js</include>
<include>libs/text.js</include>-->
<!--<include>../templates/*.tmpl</include>-->
</sourceIncludes>
<haltOnFailure>true</haltOnFailure>
<jsTestSrcDir>${basedir}/src/test/javascript</jsTestSrcDir>
<serverPort>8234</serverPort>
<specIncludes>
<include>spec/**/*.js</include>
</specIncludes>
<!--<specRunnerHtmlFileName>runner.html</specRunnerHtmlFileName>-->
</configuration>
</execution>
</executions>
</plugin>
Now i'm able to check the JASMINE specs in the console while mvn clean install as follows-
Caused by: net.sourceforge.htmlunit.corejs.javascript.JavaScriptException: Error: src/views/../../templates/menu.tmpl HTTP status: 404
I'm getting errors on template files (exceptions) not sure what this is about.
Any help on this?
Thanks.

Deploying an eclipse maven project in a remote linux server's tomcat

I'm looking a way to deploy a maven project developed using eclipse in a remote linux server's tomcat. I know you can export it as a .war file and dump it in CATALINA_HOME/webapps folder of the remote server. But for that you have to first export it to .war file and then copy the .war file in to remote server through SFTP or SCP. I'm looking for a way to do it with few clicks using eclipse or/and configuring some maven settings(in pom.xml or settings.xml). Does any one know how to do this? Any help is really appreciated.
The tool you are loooking for is called Tomcat Maven Plugin
What it basically does is it uses the API of Tomcat manager application, which you have to make sure is deployed on the Tomcat instance you are using. By default Tomcat manager should be available in the following location:
http://ip_of_your_linux_server:8080/manager/html
If it is not, please install it using the following command:
sudo apt-get install tomcat6-admin
You can configure the location of your Tomcat instance as follows:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://www.mydomain.com:1234/mymanager</url>
</configuration>
</plugin>
and then run maven mvn tomcat:deploy goal. (Either from command line of from Eclipse using m2Eclipse plugin.)
Please refer to configuration and deployment pages of the plugin for more verbose information.
The most flexible solution with adapters for many different containers like Tomcat, Jetty, Glassfish, etc. is probably Maven Cargo plugin. You can find an extensive list of examples on their homepage, so no need to paste that here again.
To remotely deploy an application you'll need to configure the tomcat deployer app on the tomcat instance. Be warned, the configuration of admin users has undergone some subtle changes between tomcat 6 and 7.
Once this is working the Maven cargo plugin can deploy war files as follows:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>tomcat-deploy</id>
<phase>package</phase>
<configuration>
<container>
<containerId>tomcat7x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.remote.uri>${tomcat.manager.url}</cargo.remote.uri>
<cargo.remote.username>${tomcat.manager.user}</cargo.remote.username>
<cargo.remote.password>${tomcat.manager.pass}</cargo.remote.password>
</properties>
</configuration>
<deployer>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<type>war</type>
<properties>
<context>${project.artifactId}</context>
</properties>
</deployable>
</deployables>
</deployer>
</configuration>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
Additional notes
The Cargo plugin supports several different containers, problem is the doco is difficult to interpret.
I haven't used the Maven plugin. It's very new

appassembler maven plugin doesn't set "execute" permissions on generated script

The AppAssembler Maven plugin does a great job of generating distribution for me. One last problem is that the generated Shell script does not have execution permissions so I need to set them manually.
I am on Linux RedHat
Does anybody know of a clean way to set them automatically?
The only way to do this is to process the file with another maven plugin like Antrun or Assembly after running AppAssembler.
This issue (see link below) has been brought up on the AppAssembler project issue tracker and it was rejected as Won't Fix.
Issue: MAPPASM-54
I think it can be set in your assembly.xml, in the fileSet tag:
<fileSets>
<fileSet>
<directory>src/resources/bin</directory>
<lineEnding>keep</lineEnding>
<useDefaultExcludes>true</useDefaultExcludes>
<outputDirectory>bin</outputDirectory>
<includes>
<include>*.bat</include>
<include>*.sh</include>
</includes>
<fileMode>744</fileMode>
</fileSet>
...
Since Maven 3.0.3 all plugins are executed in the order they are in your pom.xml. So setting the executeable flag in a platform independet manner is as easy as using the maven-enforcer-plugin right after your appassembler plugin.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.3.1</version>
<executions>
<execution>
<id>enforce-beanshell</id>
<phase>package</phase>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<evaluateBeanshell>
<condition>
import java.io.File;
print("set executable for file ${basedir}/dist/bin/mql");
new File("${basedir}/dist/bin/mql").setExecutable(true,false);
true;
</condition>
</evaluateBeanshell>
</rules>
<fail>false</fail>
</configuration>
</execution>
</executions>
</plugin>

Where to get a full list of pre-defined variables in gmaven-plugin?

Where to get a complete list of variables available in Groovy scripts executed under gmaven-plugin in Maven? Besides that, maybe someone knows where to find Gmaven documentation?
I'm aware about project and settings. I assume there are some others..
The page http://docs.codehaus.org/display/GMAVEN/Executing+Groovy+Code lists:
Default Variables
By default a few variables are bound into the scripts environment:
project The maven project, with auto-resolving properties
pom Alias for project
session The executing MavenSession
settings The executing Settings
log A SLF4J Logger instance
ant An AntBuilder instance for easy access to Ant tasks
fail() A helper to throw MojoExecutionException
This snippet in your pom should give you a better idea of what's available while running the script. Most of the interesting bits are probably in the binding.project, an instance of MavenProject.
<build>
<plugins>
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<properties>
<hello>world</hello>
</properties>
<source>
println this.binding.variables
println project.properties
println settings.properties
</source>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Resources