Set a specific build target in Jenkins?

The team I work with is standardized on Jenkins assemblies for continuous integration. Code verification launches a standard build, Cobertura analysis, and publishes the Artifactory SNAPSHOT repository. I just finished adding a new target to the main assembly file that will start Sonar, but I don’t want it to be executed every time I register.

Is there a way to schedule nightly builds of a specific build target in Jenkins? Jenkins clearly facilitates the planned builds, but he will run a regular build of the project every time. I would like to be able to designate a Sonar build target for a nightly launch.

I could, of course, create a separate Jenkins project to launch the Sonar target on a schedule, but I try to avoid this if I can. Our Jenkins server already has several hundred builds; doubling what is not very desirable for planning nightly builds. I was looking for a Jenkins plugin that could facilitate this, but I could not find anything. Any suggestions?

+8
continuous-integration hudson jenkins sonarqube
source share
2 answers

Here is one way to do this if you are fine with starting the assembly using cron or another planning tool:

  • Make the parameterized construct and use the parameter in the build file to decide whether the Sonar build target should run or not.
  • Starting the assembly remotely using HTTP POST: entering parameter values ​​in the form http://[jenkins-host]/jobs/[jobname]/buildWithParameters . Depending on the version and configuration of Jenkins, you may need to add an authentication token and include this in your URL.
  • Authenticate your POST using username and password.

    wget --auth-no-challenge --http-user=USERNAME --http-password=PASSWORD "https://[jenkins-host]/job/[jobname]/buildWithParameters?token=<token defined in job configuration>&<param>=<value>&<param2>=<value2>"

+7
source share

I am also looking for a solution to this. My real solution in my mind is to create 2 triggers in a regular build, one is a night build, the other is an SCM poll

In the configuration of the sonar plugin, it has the ability to skip assemblies caused by a change in SCM. Thus, only the nightly assembly will begin sonar analysis.

I have not had the opportunity to verify this now, but I believe that this will work.

Updated 12/19/2011 The above solution does not work if sonar analysis is called as an independent assembly step. To perform sonar analysis conditionally, you can use the following 2 plugins:

  • Conditional BuildStep plugin - this allows you to perform conditional sonar analysis
  • Jenkins Environment Injector Plug-in - This allows you to enter variables to indicate how the assembly starts.
+3
source share

All Articles