Jenkins integration test different environments - maven

I have a project that need to works on windows\linux with those databases : oracle\sqlserver.
Our project is built by Maven.
I have installed Jenkins with master\slave set-up.
master: windows + sqlserver
slave : linux + oracle
for our testing.
Jenkins - Promoting a build to different environments
but its really not helping that much for me.
I have also read Jenkins wiki : https://wiki.jenkins-ci.org/display/JENKINS/Distributed+builds
but i still cannot figure out how should i do it.
Since compiling our code takes a lot of time i would like to do it just once than use the final result and test it on those environments master and slave.
build succes only if he runs on both environments.
I have also noticed that i cannot invoke on "post steps" at jenkins to do it. i didn't find any plugin that can really help with deploying and testing on the slave.
I have read somewhere that maybe i should split it to 3 jobs and not to use one job.
first job compiles, and then other jobs are running integration test.
you can look at : http://zeroturnaround.com/rebellabs/the-correct-way-to-use-integration-tests-in-your-build-process/
I hope you could advise to me how should i do it.
Thanks

I would split the build up as follows:
Job 1 compiles the code, runs unit tests and builds your deployable artifact (since you're using Maven, I assume you have a JAR or WAR file)
Job 2 deploys and runs the artifact - you could use build parameters to specify environment-specific criteria.
Job 3 runs the integration test and reports results.

Related

How can I run a task that requires multiple containers?

This is my first question so please presume ignorance and positive intent.
As part of our build pipeline I need to run what our dev team calls "unit tests." These unit tests are run via an ant target. Before running that ant target we must spin up, configure and partially populate (the ant target does some of the population) several containers including:
application server
ldap instance
postgres instance
It looks as if each task only supports a single container. Is there a straightforward way to get all of these running together? Ideally I could create a task that would allow me to specify a pod template with the commands running in one of the containers of that pod.
I realize that I could hack this together by using the openshift client or kubernetes actions but I was hoping for something a bit more elegant. I feel like using either of those tasks would require that I build out status awareness, error checking, retry logic, etc that is likely already part of the pipeline logic and then parse the output of the ant run to determine if all of the tests were successful. This is my first foray into tekton so accepted patterns or idioms would be greatly appreciated.
For greater context I see these tasks making up my pipeline:
clone git repo
build application into intermediate image
launch pod with all necessary containers
wait for all containers to become "ready"
execute ant target to run unit tests
if all tests pass build runtime image
copy artifacts from runtime image to external storage (for deployment outside of openshift)
Thank you for your time
Have a look at sidecars. The database must be up and running for the tests to execute, so start the database in a sidecar. The steps in the task will be started as soon as all sidecars are running.

Cucumber test failed first time build in Jenkins but when run build multiple times build get pass

I am using a cucumber test with multiple features file for testing spring boot project, test run locally passed and when go to Jenkin build it gets failed but when I am trying multiple time build(3-4 times) its get succeed and build pass without doing any changes.
I don't understand what wrong I am doing is there any data related problem or Jenkin configuration problem or multiple feature file problems.
please guide what I am missing?

Jenkins : Run specific Maven goal on meeting certain condition

I have 3 applications which are integrated with Jenkins.
Now I want to do following tasks on them in Jenkins :
After detecting change in SCM, build the application and deploy artifact(jar) to my local Nexus Repository.
Do the static code analysis.
Deploy the application to UAT server.
Till now, I have been successful in achieving all this requirement.
Problems:
I found that
I don't need to do static code analysis for every SCM change as it takes around 15mins. It will enough If I perform this action daily once or twice(periodically).
I don't need to do update war on UAT for each SCM change, but based on SCM change log(ie if change log contain '#deploy' keyword then upload)
My not-so-good solution:
For the time being, I have create 3 different jobs for a one project to fulfill above requirements, which is obviously not a correct thing to do.
So my question is, how can run specific Maven goal based on certain conditions in Jenkins?

any library to check marathon deployment status

I have a bunch of marathon docker tasks that are run on our test deployment machines.
There is a Jenkins CI job, that triggers the deployment a whole bunch of docker containers that are run on marathon-mesos cluster. (3 mesos-slaves, 1 master and 1 marathon.)
There is another downstream jenkins job (a automated test suite) that is triggered after above job. Presently, we wait for sufficient time, so that deployment gets completed then only we proceed with this automation testsuite. I want to change this behavior. I know marathon exposes rest APIs using which I can determine if I am good to go - after all the containers are deployed and all health checks are passing - for running the automation test suite.
Question is: Is there any library already out there for marathon, that I can reuse to accomplish above task ? I do not want to reinvent the wheel.
When I posted this question, I had java library actually in mind, but forgot to mention that. I find #michael 's libraries are also very good. But this is what I settled upon. Marathon-client. I think I saw this, while browsing through mesosphere repositories but somehow missed it.
This is the library: marathon-client
I've successfully been using the two following libs:
Go: gambol99/go-marathon
Python: thefactory/marathon-python

Check deployment to application server after a build with Jenkins

I have a job configured to automatically deploy an application to a running server. I would like to know if Jenkins provides a way to verify if this application was deployed successfully. Ideally, the build should fail when the deployment fails.
Jenkins has a rundeck plugin which might perhaps be useful.
Rundeck deploys the application, and can be setup to trigger a post-deployment build on Jenkins to perform tasks like running integration tests.
Jenkins could be used to report the status of the deployment, however it might make more sense to use rundeck's dashboard instead.

Resources