Fl4m3Ph03n1x

Fl4m3Ph03n1x

Excoveralls plugin for jenkins CI?

Background

After a lot of hard work we finally got a Jenkins CI pulling code from out GitHub repositories and are now doing Continuous Integration as well as Deployment.

We get the code and only deploy it if all the tests pass, as usual.

Now I have checked that there are a number of plugins for Java that besides running the tests, also do test coverage, like Cobertura.

But we don’t use Java. We use Elixir.

In the Elixir world, we have excoveralls, which is a facade for the coveralls API. The coveralls API supports jenkins so it stands to reason I would find a Coveralls Plugin for Jenkins.

I was wrong. There is nothing.

Questions

So now I have a test coverage metric that is basically useless because I can’t integrate it with Jenkins.

Are there any Erlang/Elixir plugins one can use with Jenkins for code coverage?

I also created a Issue in the projects ( which seems to be abandoned … ) Is there any jenkins plugin compatible with this? · Issue #167 · parroty/excoveralls · GitHub

Marked As Solved Switch mode

hauleth

hauleth

covertool exports coverage data in Cobertura format that is supported by Jenkins.

Also Liked

shanesveller

shanesveller

Try using a JUnit Formatter Elixir package together with the junit pipeline step in your Jenkinsfile.

Fl4m3Ph03n1x

Fl4m3Ph03n1x

I have tested both suggestions.

@shanesveller This solution works and is quite nice. It forces me to change the test_helper.exs but that is a minor inconvenience overall. It is nice but it only offers the most basic of reports and for me this is where it fails.

@hauleth The option I decided to go with. Yes, making the Jenkinsfile work for Cobertura was a nightmare, specially because in previous versions it was not even possible and because there contradictory information scattered all over the place.

However, once you get that Jenkinsfile going, you get to rip those sweet reports from Cobertura. Cobertura was made with Java in mind, there is no two ways about it. In the reports you see things like Class coverage and such, but you can easily translate that do modules. The interface offers a lot more information and tracks coverage over time, which is something I actually want.

For future notice, here is my Jenkinsfile:

pipeline {
  agent any

  environment { 
    SOME_VAR = "/home/deployer"
  }

  stages {
    stage("Build") {
      steps {
        sh "MIX_ENV=test mix do deps.get, deps.compile"
      }
    }

    stage("Test") {
      steps {
        sh "mix test --cover"
      }
    }

    stage("Credo"){
      steps{
        sh "mix credo --strict"
      }
    }

    stage("Deploy"){
      when{
        expression{
          env.BRANCH_NAME == "master"
        }
      }
      steps{
        sh '''
         echo "Deploy with AWS or GCP or whatever"                                                         
        '''
      }
    }

  }

  post{
    always{
      cobertura coberturaReportFile: "coverage.xml"
    }
  }
}

Of notice:

  1. I am extremely Nazi with my code, so I also use Credo. You can further configure it as to not blow the entire pipeline because you missed a new line at the end of file but as I said, I am quite Nazi with my code.
  2. The Deploy stage only runs if the pushed branch is Master. There are other ways of doing this, but I found it that having this way for a small project was good enough.

Overall I like covertools for now but I don’t know if the first solution has the same potential. At least I didn’t see it.

Hope this post helps!

Where Next?

Trending in Questions Top

jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
silverdr
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated! To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead. Sta...
New
saveman71
Hello ! We want new/edit form pages to POST/PUT to their own URL rather than the resources REST defaults (post /things, put /things/:id)...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
michallepicki
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New

We're in Beta

About us Mission Statement