2

I have a pipeline job that consists of several stages, each of which takes several hours. Before pipelining, each stage was its own job, and I was using the Heavy Job Plugin for some of them. Now it looks as though the "properties" command allows to specify the "HeavyJobProperty". I managed to get its syntax correctly thanks to this question.

My pipeline script looks likes this:

node ('<label>') {
    ws ('<mydir>') {
        // Mark the code checkout 'stage'....
        stage 'Checkout'

        git url: '<repourl>'

        stage 'Build'
        properties ([[$class: 'HeavyJobProperty', weight: 8]])

        sh '<mybuild>'
    }
}

Unfortunately, this doesn't seem to work, when executing the script, I get the message:

ERROR: cannot apply hudson.plugins.heavy_job.HeavyJobProperty to a WorkflowJob

Does anyone have an idea how I get this to work?

It looks as though the plugin simply hasn't been adapted to pipelining jobs yet, even though the pipelining docs shows the HeavyJobProperty.

Community
  • 1
  • 1
olenz
  • 567
  • 1
  • 7
  • 15

1 Answers1

3

The heavy job matrix plugin isn't compatible with the pipeline plugin, nor does it have an issue open to request it (see https://github.com/jenkinsci/pipeline-plugin/blob/master/COMPATIBILITY.md)

As a work around, you could keep the old build jobs you have and call them from your pipeline.

The pipeline step you'll be looking for is 'build'. If you use the snippet generator it'll let you generate the syntax for calling it, including any parameters you need to save.

If you need the same workspace as the pipeline, you can configure the job you're calling to use the workspace of the pipeline job. You can set the workspace in the "Advanced" section of the "General" heading. It'll be the "Use Custom Workspace"

Caveats of that solution: 1) The heavy job won't be independent anymore. 2) I think it won't work well if you have more than one node.

Sam Sieber
  • 490
  • 6
  • 12
  • If you install the plugin and you look at the "Pipeline Syntax" documentation of the "properties" command, I see docs on "$class: 'HeavyJobProperty'". From that I concluded that the plugin is compatible. Or does the pipeline syntax automatically pick up the plugins? – olenz Jul 04 '16 at 12:52
  • I think that the pipeline syntax automatically picks up things that implement the right interfaces in code. My guess is that that they happen to implement an interface by chance, and that they aren't doing anything under-the-hood to make sure it's compatible. As an example of something that loads, but doesn't work: I've been hacking on the gradle plugin recently to try to make it work with the pipeline syntax, and while it loads correctly now, it still doesn't modify the build status as it should. – Sam Sieber Jul 05 '16 at 15:42
  • So maybe if I find the time I'll try to adapt the plugin for pipelining. Thanks, Sam! – olenz Jul 06 '16 at 07:46