0

Until recently, we created our Jenkins jobs by hand. We have a policy that the code is checked using FindBugs, Checkstyle and PMD, and any project that exceeds certain thresholds is considered unstable and is not allowed to deploy its artifact to our Maven repository.

In Jenkins, when I create a "Maven project", I get the metrics configuration under "Build Settings". If any threshold is exceeded, the build is considered unstable, and the Post-Build Action "Deploy artifacts to Maven repository" is not executed. This is how it should be.

However, in our generated jobs, which are generated using mavenJob(), the situation is different. Here, the metrics are added to the publisherContext, and thus if the threshold is exceeded, the build is still considered unstable, but nothing prevents the artifact to be deployed to the Maven repository.

Did I miss something? How can I add the metrics to the Build Settings as before?

eerriicc
  • 1,124
  • 4
  • 17
  • 29

1 Answers1

0

You can use deployArtifacts{} with evenIfUnstable(false) to set this explicitly:

mavenJob('example-job') {
    publishers {
        deployArtifacts {
            evenIfUnstable(false)
        }
    }
}
SevenEleven
  • 2,326
  • 2
  • 32
  • 32
  • Thanks! I noticed that the sequence of publishers is important. I generated the metrics publisher after the deploy publisher, and it still deployed. I had to generate the metrics publisher before the deploy publisher, and now it works. – eerriicc Sep 09 '16 at 15:24