Jenkins file Script - jenkins-pipeline

Can any one please tell me that we can generate entire Jenkins file script with snippet generator?
I have to write Jenkins file including steps like Check Out Code, Build using Gradle, Pushing to nexus, Generate Sonar Report and Generate Package for deployment.

You can generate all the parts with the snippet generator but you have to put it all together in your defined stages.
Maybe you can start from examples or search in github for jenkinsfile
But be aware of the two different flavours of the Jenkinsfile:
scripted
declarative

Related

Exporting Jacoco*.exec files to Sonar without Maven or ANT or Jenkins

I don't know if this has been asked before; from a quick search I couldn't find anything relevant, but please do forgive me if I've missed it.
My question is we need to send the jacoco.exec output file to Sonar without using any other tool like Jenkins etc.
Below are the steps we did to configure Jenkins & Sonar
Jacoco agent code is setup and injected into our Application server (with WAS Console)
SonarQube is installed and configured in another server
When we perform manual execution on the application, jacoco is generating a Jacoco*.exec output files (File is in binary format)
Our challenge is how do we send this output file to Sonar, such that it reads and generates reports in a readable format?
PS. When integrated this with Jenkins and Maven, we are able to export this report to Sonar and see the reports properly. But, without using Jenkins and Maven, is there a way to export the Jacoco.exec file to Sonar and generate the reports??
Hope I am clear with my question. Please respond if any part of the question is not clear.
Thanks in advance for ur help!!

Two Sonar reports generation for 2 branches under one project

I have a java-maven project named clarity which has one pom.xml file. we recently created a bitbucket account and created two branches one for development team and one for reporting team. It's like two teams make changes to their own branch. Now I need to configure jenkins for running separate sonar reports for this two branches with one project itself, how do i that. Should I change the pom.xml file or need to specify something in jenkins jobs. Please mention clearly as I am new to this jenkins config.
Any help is appreciated, Thanks :)
You should differentiate the two copies using the sonar.branch analysis parameter, which you should be able to pass into the Maven analysis on the command line using, E.G. -Dsonar.branch=reporting

How to trigger a batch file after successful Maven Build?

I am new to Maven build. Can some one let me know if there is any way we can trigger a job which will run a batch file after successful completion of build in Maven?
Since you didn't provide details on how you are invoking maven, I'm going to just assume some things.
Continuous Integration: If you are using some kind of continuous integration like Jenkins/Hudson, or Travis CI, you should be able to add your batch file as a post-build step that gets executed on success of the build. Alternatively, you could have a separate job that runs your batch script that gets kicked off by the maven build's job.
IDE Configuration:
If you are trying to do it with Intellij or some IDE, you will likely need to make a batch configuration that runs your maven build and then your desired post-build batch file.
Command line/mvn directly:
If you are running this by yourself on the command line using normal mvn install commands, you are either going to want to circle back to having a batch file that kicks off maven for you and then runs your next script, or look into a plugin similar to this question (Note that there are some concerns with this approach, so be careful).
If none of these scenarios describe your situation, you are going to want to provide more information to your question before you get any solid feedback.
Thanks!

How do I gather TeamCity code coverage reports from multiple projects into one report?

We use the build in coverage application in TeamCity 6 (about to upgrade to 7.1)
If we wish to see the code coverage (or other metrics) of a particular build it is fine as we can navigate to that build, but it would be great if we could pluck out a few interesting metrics from all/some of the current projects/build configurations and display them all together.
For convenience I would expect the new display to be accessible from within TeamCity itself, however if there are solutions that require a separate solution we could look at them.
If you want to compare a set of common metrics (e.g. code coverage) across different projects and over time then SonarQube is probably what you want.
You can integrate it with TeamCity by adding a sonar-project.properties file to each project and calling sonar-runner from a command line build step.

Template plugin for Jenkins

Is there any plugin available in Jenkins which allows you to reuse shared configuration across the jobs.. e.g I can define a template for Continuous Integration and other template for Running Tests and create multiple jobs from these template for different branches.
I know template plugin is available in Enterprise Jenkins but is there something similar available for jenkins open source?
I am looking for something similar to
here
I have found ez-templates plugin to behave well for Jobs templating. It is very young project and you will have to build it by yourself (which is very simple, see below), but still it is much more powerful than Template Project Plugin as it supports any types of jobs.
How to build:
Install Maven 3
Clone/download the ez-templates git repo
Run 'mvn install' from the ez-templates checkout folder
Once build is ready go to the 'target' folder and find the ez-templates.hpi which is self contained plugin binary.
How about the Template Project Plugin?
The Job Generator Plugin was released after this question was asked, which may fulfil some people's needs.
Unfortunately the Template Project Plugin still has some issues, particularly in that it lacks support for job parameters.
We use the Jenkins job builder to automate creation and management of our jenkins jobs. It was basically built to allowing share configurations across jobs so you can easily create the same jobs with multiple configurations. Check it out: http://docs.openstack.org/infra/jenkins-job-builder
You can use the Copy Project Link plugin. https://wiki.jenkins-ci.org/display/JENKINS/Copy+project+link+plugin
What I have done is to create a disabled (dummy) pre-configured job and when I want to create another one with the same configuration I just copied by using this plugin.

Resources