Actually I already have application with java as a backend and backbonejs app as frontend. Both are completely separate. Now I have introduced grunt tasks in my front end which I need to be executed before packaging war file. So that packaged war files have files generated by grunt task.
Locally I can execute grunt tasks from maven.
But for deployment we have been using cloudbees. I tried searching on internet but I haven't got any solution. Though I have gone through a question "How do I get a grunt task working with a Cloudbees Jenkins build" and also through documentation but still I am clueless.
My guess is I need to run grunt tasks post build as a shell script.
So how to setup node.js environment for existing maven project on cloudbees?
This is what I do to run grunt - I have it located in a script bin/build-ci
Call the script below from a shell build step in Jenkins
If you are running grunt commands, then they need to be run in the same build step as the environment is manipulated (and these changes are not carried from one step to the next).
# This script is normally in a ./bin/ subdirectory, so we grab BASEDIR as the parent
BASEDIR=`dirname $0`/..
curl -s -o use-node https://repository-cloudbees.forge.cloudbees.com/distributions/ci-addons/node/use-node
NODE_VERSION=0.10.18 . ./use-node
# Make sure grunt and grunt-cli are in your package.json manifest
npm install
export PATH=$BASEDIR/node_modules/.bin:$PATH
grunt
Related
Setting: I inherited a project that I need to update the UI for
I have a spring boot application that has an angular front end.
If I make UI changes in the front end, code at src/main/web/, they do not appear in the application that launches when I run mvn spring-boot:run
The application refers to files in the src/main/resources/static/ instead. This folder seems to contain 'compiled` front end scripts.
Question
I am trying to recompile src/main/web/ files into the src/main/resources/static/, how do I do that?
Notes
I have tried
bower install
npm install
mvn install
mvn clean
They have grunt here. Running the grunt serve command will show my updated front end files, this, in a sense "works", but mvn spring boot runs the full application and it is necessary that this command works.
An ls of the main directory shows:
Gruntfile.js bower_components package-lock.json pom.xml src
README.md package.json swagger.json
bower.json node_modules packageOld.json target
The code is being compiled by grunt, not bower or npm or mvn.
grunt clean build
I'm trying to setup a custom build for an OpenShift Online 3 application, following the instructions for S2I scripts. I tried this with both an application based on the OpenJDK catalog template, and one based on the Red Hat JBoss Web Server (Tomcat) catalog template.
My assemble and run scripts are recognized during the build, however I couldn't find either the application artifacts directory, nor the application source one, from inside assemble. In the example script they are located at /tmp/s2i/artifacts and /tmp/s2i/src, but in my case those directories don't exist. The documentation says that
Before executing the assemble script, S2I untars that file and places its contents into the location specified with the --destination flag or the io.openshift.s2i.destination label from the builder image, with the default location being the /tmp directory.
but I have no idea where that --destination flag or io.openshift.s2i.destionation label are defined. Also, I tried to ls -la the /tmp directory from the assemble script, and I could only find an empty /tmp/src directory.
In addition to this, my assemble script tries to build the project with Maven: however, the mvn command cannot be found. I tried to log into the pod, and mvn cannot be found there either. However, when I make a new build without any custom scripts, and watch the build logs, I can see that it's indeed running Maven:
Found pom.xml... attempting to build with 'mvn -e -Popenshift -DskipTests -Dcom.redhat.xpaas.repo.redhatga package --batch-mode -Djava.net.preferIPv4Stack=true '
So where can I find the source location, and the mvn executable from the assemble script?
I have a big issue. I'm trying to deploy Spring Boot + Angular 2 web app on heroku but don't know how to do it. I tried several things including:
Making a .war file and deploying it to heroku (source here)
Deploying project as standard java application (source here)
but none of these worked. The first attempt didn't work because I constatly got 404 not found, and the second one didn't work due to, I think, some jar file wasn't found in the location which was described in the Procfile.
Can anyone give me a link, an example, or write a step by step instruction how to achieve this. Thank you.
The most simple way to do it:
run ng build in angular 2 project root (if you are using angular-cli) and copy the content of dist folder to src/main/resources/static/.
create Procfile (for maven):
web: java $JAVA_OPTS -Dserver.port=$PORT -jar target/*.jar
commit and push changes.
Also, you need spring-boot-starter-web present in dependencies. Which has embedded tomcat and automatically configured to serve static content from the static folder.
If you deploy your app as a standard Java application, you can combine it with the Node.js buildpack to run ng build during the Heroku build.
$ heroku buildpacks:add heroku/nodejs
$ heroku buildpacks:add heroku/java
$ git push heroku master
The Node.js buildpack will detect your package.json, install Node.js and run npm. Then the Java build can proceed as normal.
There is a guide for doing something very similar but with Grunt: Using Grunt with Java and Maven to Automate JavaScript Tasks
Use JHipster: https://jhipster.github.io
Once installed, run:
$ yo jhipster
Then run
$ yo jhipster:heroku
I have a question according to automate my project lifecycle.
Now i do this manualy:
build my project with Ant, get target jar, rename it manualy (add
suffix, like version2.0-myProject.jar);
connect to remote server via ssh, open FreeComander and copy jar
file and INI-properties files to different folders on remote server;
Remoutly run my application throws putty (exec bat file on server,
which contain all cmd run command. This .bat contain plink.exe remote command to Lunux server, whoes contain instance of app).
What i want to do:
i want to automation deployment procces, include build phase and app run phase,
i want to do this:
When buld executed, user asked for output-jar file suffux(like varian2-myapp.jar), ask user for properties file with what programm will execute later, and ask user for Allocated memory for JVM (now it is part of cmd comand in .bat file)
My app is simple, contains 15 Classes and 3 external libs. I want to make deployment easy and automate this process, i learn that Maven or Ant Build can help me. Please say, what way is more comfort for my task of using this build systems.
With Maven you can use the Maven Release Plugin to deploy your package (which could be a zip with your jar and other dependencies for example) to a Maven repository (which you could be running in one of your server).
This page should get you started:
http://maven.apache.org/maven-release/maven-release-plugin/
With Ant, you can use Apache Ivy instead:
http://ant.apache.org/ivy/history/2.2.0/index.html
You then need a way to tell the server serving your app to pull the package and start using it (install it).
You could write a simple script that pulls the repo, which you trigger remotely, maybe using
plink -m
as you are doing now, or use one pre-built automation software, like https://puppet.com/.
I am trying to run an executable jar file through jenkins. What I am trying to achieve here is I have an executable jar file created and is residing locally in my machine. I want to put it in Git and then run it in jenkins. Is there some how I can do this? I am totally new to Jenkins and if someone can help it will save me a lot of time.
You can do nearly everything you want with Jenkins since you can have it run arbitrary scripts / executables.
If you want to put this .jar in git, then the Jenkins jobs will retrieve it when it fetches the repo. Then you just need to add a script shell step to the build, and to put your command line java my.jar my.class ....
On the other hand, it's sometimes frowned up to put binary files in git. It's true in particular if the .jar will need to be often updated. Hence you might want to provide the .jar to the Jenkins job using alternative methods. For example using a maven repository.