Jenkins-Pipeline, warnings-ng-plugin reports no workspace found

30 Views Asked by At

I have setup a declarative Jenkins-Pipeline which runs fine so far. During a post-action I would like to publish issues found by warnings-ng-plugin. This had worked till 4 weeks ago or so. Suddenly the publish doesn't work anymore.

This is my post-action

post {

  always {
    script {

      echo "ISSUES_DOXYGEN: ${ISSUES_DOXYGEN}"
      echo "ISSUES_PCLINT: ${ISSUES_PCLINT}"
      echo "ISSUES_AXIVION: ${ISSUES_AXIVION}"
      echo "env.Workspace: ${env.WORKSPACE}"

      if (env.BRANCH_NAME == 'main') {
        // provided by warnings-ng-plugin
        publishIssues (
          issues: [
            ISSUES_DOXYGEN,
            ISSUES_PCLINT,
            ISSUES_AXIVION
          ]
        )
      } else {
        // provided by warnings-ng-plugin
        publishIssues (
          issues: [
            ISSUES_PCLINT
          ]
        )
      }
    }
  }
}

Whenever I run the pipeline everything works but the post-action now always fails. All steps shown in the WebUI are green, only the overall status is red ...

This is the exception I got:

ISSUES_DOXYGEN: io.jenkins.plugins.analysis.core.steps.AnnotatedReport@781b8ff7
ISSUES_PCLINT: io.jenkins.plugins.analysis.core.steps.AnnotatedReport@260d6b49
ISSUES_AXIVION: io.jenkins.plugins.analysis.core.steps.AnnotatedReport@6c4499e0
env.Workspace: null

Error when executing always post condition:
Also:   org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: 82ec7aae-3f00-4eae-bfe5- 35eb2b1a9906
java.io.IOException: No workspace available for 
io.jenkins.plugins.analysis.core.steps.PublishIssuesStep$Execution@52fe54f0
    at 
io.jenkins.plugins.analysis.core.steps.AnalysisExecution.getWorkspace(AnalysisExecution.java:99)
    at io.jenkins.plugins.analysis.core.steps.PublishIssuesStep$Execution.run(PublishIssuesStep.java:415)
    at io.jenkins.plugins.analysis.core.steps.PublishIssuesStep$Execution.run(PublishIssuesStep.java:372)
    at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)

As you can see, the Variable env.WORKSPACE is indeed null. But all the variables used in the publishIssue command are there.

How can I fix this?

Plugin-Version is 11.2.2 Jenkins-Version is 2.440.1

Any idea?

Thanks in advance


According to the suggestion of @Noam I added the following

post {

  agent {
    node {
      label AGENT
    }
  }

  always {
    script {

      echo "ISSUES_DOXYGEN: ${ISSUES_DOXYGEN}"
      echo "ISSUES_PCLINT: ${ISSUES_PCLINT}"
      echo "ISSUES_AXIVION: ${ISSUES_AXIVION}"
      echo "env.Workspace: ${env.WORKSPACE}"

      if (env.BRANCH_NAME == 'main') {
        // provided by warnings-ng-plugin
        publishIssues (
          issues: [
            ISSUES_DOXYGEN,
            ISSUES_PCLINT,
            ISSUES_AXIVION
          ]
        )
      } else {
        // provided by warnings-ng-plugin
        publishIssues (
          issues: [
            ISSUES_PCLINT
          ]
        )
      }
    }
  }
}

still no success, workspace is still null. Also "label" is missing ...

Variable AGENT is used in other steps too with success.

Can someone answer with an example that works, please? It seems that I am missing the clue what to add where...


Found a solutions that works now.

I need to change the global agent directive from none to 'any'.

pipeline {
  agent 'any'
  ...
}

After that the publishIssue step works again.

0

There are 0 best solutions below