How to Set Maven Parameters in OpenShift - openshift

I'm completely new to OpenShift and so far ran in hundreds of bugs while trying to create my first application. Now I want to configure Maven to use my own goals. So far I tried:
adding a Jenkins and configuring the Maven Build - the Jenkins didn't take up the changes and finally stopped building altogether
adding a file .openshift/action_hook/pre_build with the content export MAVEN_ARGS="clean package -Popenshift" as explained here
adding a file .openshift/action_hook/build with the content mvn clean package -Popenshift as explained there
Evidently, the documentation is somewhat obsolete... so what is the correct way?

I finally managed to get the Jenkins to build with my goals. The misconception was that it would use the configured Maven goals INSTEAD of the default ones, when it would just use them additionally (he never had to, since the shell script failed). So deleting the script and adding a custom Maven build works.

Related

Finding unused plugins in HUdson

I am using Hudson 3.3.1 in my org and I see a bunch of unwanted plugins being added to the hudson. I am planning to get rid of those unwanted or unused plugin. I thought of scanning all the job config files, but I have following questions.
If there are plugins that not being used by hudson job configs, but used by hudson configuration, What\which files should I search for?
In configs what should I be searching for. Pages what ever I am searching for is redirecting to jenkins pages.
I read through the following post How to list all unused jenkins plugins?
I tried installing this plugin http://updates.jenkins-ci.org/download/plugins/plugin-usage-plugin/ , but it started throwing out error as I believe it is supported only by jenkins
I added an answer to the question you linked that adds steps on how to search the main Jenkins configuration file as well as individual job config files. If you use the code in the linked question you should be able to find all the used plugins.

DIY Tomcat, where is the webapp folder on the local git repo

following OpenShift tutorials, creating a tomcat application and clone it, the local repository will contain a pom.xml, webapp folder.
What's the equivalent on a diy application that contain a diy and misc folders
Thank's in advance, any help is appreciated cause I'm really stuck here !?
Update
Well I've install a Tomcat 8 DIY application following this tutorial here everything works fine, I can see the Tomcat page in the browser, the problem is how to deploy a .war file.
For a Tomcat 6/7 application on OpenShift, the local git repository have this structure:
____Tomcat7/6
|_________ webapp
|_________ src
|_________ pom.xml
But for a Tomcat 8 DYI application I have this structure
________Tomcat8/diy
|__________ Diy
|__________ misc
|__________ readme
So Where to deploy my .war files, cause there is no webapp folder?
The title of your question suggests that you are mixing up at least 5 different, completely independent & orthogonal tools and concepts:
Git is a version control system ("push", "local repo")
Maven is a build tool ("pom.xml")
Apache Tomcat is a servlet container ("Tomcat 6/7/8")
rhc is some client tool provided by yet another cloud computing platform ("OpenShift")
Your code is the stuff that you have written, it's completely under your responsibility.
Before you start doing anything, please make sure that you have at least some basic understanding of what each of these tools does. Then ask yourself whether you really need Tomcat 8 instead of Tomcat 7, and whether a 2 year blog post about the compilation of Tomcat 8 within an OpenShift gear is the best source. All these deployment details can change pretty quickly, if it worked two years ago, it's not guaranteed that it would work now.
I've never worked with OpenShift, but as far as I understand, the basic idea is this:
You write your code
You create your OpenShift account and allocate some "Gear" (or "Dyno" or whatever...) for your application
You commit your source code (/src) and the files that are necessary for the build (pom.xml), and use git to push it to the repository OpenShift gave you.
OpenShift then uses your pom.xml and builds all the WAR-files on it's own
Then you can use your rhc client tool to start your application, if that's not done automatically.
Some of these steps can be changed.
If you really have to, you can indeed compile your own Tomcat8, the tutorial you linked tells you how (more or less. The dude who did it obviously knew what he was doing there, so he might have skipped some details that seemed trivial to him).
Furthermore, if you really want, you can deploy pre-packaged WAR-files, by deliberately removing all the stuff that is necessary to build you app (removing pom.xml and all the /src), and instead adding the packaged application to your git repo, and then pushing it all to OpenShift. Then it will skip the build step, and just run what you gave it. OpenShift seems to provide some information about this deployment strategy: https://help.openshift.com/hc/en-us/articles/202399740. Please read the documentation and make sure you understand what you want to do. For example, filter-branching your git repo and removing all source files you have ever written is not a good idea, even if you don't need these files on OpenShift.
Currently, I don't see anything of the standard tomcat directory structure in the tree that you show. Instead, there seem to be just some basic ruby-scripts or some other default-demo-app-stuff... That's why it's called "do it yourself". If you don't want this, take a standard Tomcat7 app.

Openshift: how to import MySQL driver to the tomcat/lib directory

I would like to connect my web application (running on tomcat 7) to MySQL (v5.6.20). It is ok if I include the driver mysql-connector-java-5.1.31-bin.jar into my web application. But would like to have it for all my apps. On my local computer, I put the file in tomcat/lib and everything is fine.
How to do the same with openshift? Is it a bad idea to do so?
I am a total beginner. What I do to upload my application (war files) is
git add --all
git commit --m "text"
git push
Thanks a lot for your help!!
Here are two KB articles from the Help Center that I think will help you get going, the first shows how to use the pre-configured database connections that come with each of the Java containers on OpenShift (https://help.openshift.com/hc/en-us/articles/202399720-How-to-use-the-pre-configured-MySQLDS-and-PostgreSQLDS-data-sources-in-the-Java-cartridges), They are very easy to use.
The second shows you how to include external libraries (jar files) inside your application without using maven (https://help.openshift.com/hc/en-us/articles/202399730-How-to-include-libraries-jar-files-in-your-java-application-without-using-Maven).
A third option, if you are using a Maven based project (similar to the default applications that come with the Java cartridges), is to add the mysql driver as a dependency to your pom.xml file, and it will be loaded into the correct place in your application when you do a git push. If you want to go that route, I think that this article will help: http://www.java-tutorial.ch/core-java-tutorial/mysql-with-java-and-maven-tutorial

How do I remove the -C parameter from cvs update in a Hudson build

I can't find where I can configure the parameters that hudson uses in CVS checkout and update.
I have a situation where I modify build properties file locally before I kick off a hudson build. However because the cvs update contains a '-C' it overwrites my local changes. Do you know of a way where I can remove this?
Any help much appreciated,
Paul
You are confusing me. How do you change the build properties locally before kicking off the build? If I need to do something like that, I first get the code from my SCM and then run a script to make changes (like changing the build properties) and than start the actual build process (usually by kicking off maven or ant). The whole purpose of a CI (what Hudson is supposed to be used for) is to have a reproducible build. Manual steps during a build usually do not count as reproducible.

Hudson build fails when run in browser but works from command line

I am setting up a new Hudson task (on WinXP) for a project which generates javascript files, and performs xslt transformations as part of the build process.
The ant build is failing on the XSL transformations when run from Hudson, but works fine when the same build on the same codebase (ie in Hudson's workspace) is run from the command line.
The failure message is:
line 208: Variable 'screen' is multiply defined in the same scope.
I have tried configuring Hudson to use both ant directly and to use a batch script - both fail in Hudson.
I have tried in Firefox, IE6 and Chrome and have seen the same issue.
Can anyone suggest how we can workaround this problem with Hudson?
Problem solved.
Our build is actually dependent on jdk 1.4.2, and Hudson appears to run using 1.6. When I set Hudson to run as a service, it ran as my local user, which meant that it picked up the 1.4.2 JAVA_HOME environment variable - and therefore worked.
I guess another possible solution is to configure Hudson to use 1.4.2 by default.
I would assume this is not an issue with Hudson directly, as it is with the build script and/or the environment itself.
Is your build script relying on certain environment variables being defined, or worse, the job running from within a certain directory structure (i.e. it works if it's run from under /home/mash/blah but not from under another directory like /tmp)? Is the build script making reference to external files by relative paths?
These are the things I would look into. For environment variables, you can tell Hudson to pass these into Ant. For the other issues, you probably want to change your build script. Check the console output provided by Hudson, and maybe set Ant to print verbose/debug messages to get a better idea about the environment/filepaths.