Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-61195

How to avoid "Checks if running on a Unix-like node" in BlueOcean output

      In our pipelines a step's output appeared recently:

      "Checks if running on a Unix-like node"

      We figured out with a single search, that it's the output of a function "isUnix()". Our problem is, that we are not calling this plugin. In the classic UI it's also visible.

      [Pipeline] isUnix
      

       Is it somehow possible to hide these messages in Blue Ocean. As I wrote, we are not calling this function, it has to pipeline or docker plugin.

      Jenkins 2.204.2 LTS

      • docker-commons:1.16
      • docker-workflow:1.21
      • pipeline-build-step:2.11

          [JENKINS-61195] How to avoid "Checks if running on a Unix-like node" in BlueOcean output

          Gabor Mandity added a comment -

          We have updated our Jenkins instances to 2.204.5 LTS, but the problem is still there.

          • docker-commons:1.16
          • docker-workflow:1.23
          • pipeline-build-step:2.11

          Gabor Mandity added a comment - We have updated our Jenkins instances to 2.204.5 LTS, but the problem is still there. docker-commons:1.16 docker-workflow:1.23 pipeline-build-step:2.11

          Florian Ramillien added a comment - - edited

          Same problem for us, we have implemented a small wrapper around sh/bat commands, and devs see a lot of uneeded 'isUnix' steps.

          def call(cmd) {
            if (isUnix()) {
              sh cmd
            } else {
              // If we use "returnStdout", need to remove command itself from stdout to work like 'sh' command
              if (cmd instanceof Map && cmd.returnStdout) {
                cmd.script = '@' + cmd.script
              }
              bat cmd
            }
          }

          If some steps can me marked as "invisible" (steps without side effects maybe ?) this could be great.

          Florian Ramillien added a comment - - edited Same problem for us, we have implemented a small wrapper around sh/bat commands, and devs see a lot of uneeded 'isUnix' steps. def call(cmd) { if (isUnix()) { sh cmd } else { // If we use "returnStdout", need to remove command itself from stdout to work like 'sh' command if (cmd instanceof Map && cmd.returnStdout) { cmd.script = '@' + cmd.script } bat cmd } } If some steps can me marked as "invisible" (steps without side effects maybe ?) this could be great.

          to mee it seems by some magic the "isUnixStep" (Step) is launched, as that seems to provide exactly this message:
          https://github.com/jenkinsci/workflow-basic-steps-plugin/blob/master/src/main/java/org/jenkinsci/plugins/workflow/steps/IsUnixStep.java

          In general it seems the "isUnix" is some API-Implementation as part of the Launcher:
          https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/Launcher.java

          I think it boils down to the fact that the docker-workflow-plugin (providing the docker.xyz steps) is using the isUnix Step implementation of the node, and not the isUnix API of the launcher in shell() method like here: https://github.com/jenkinsci/docker-workflow-plugin/blob/master/src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy

          now, can we do anything here?

          Peter Niederlag added a comment - to mee it seems by some magic the "isUnixStep" ( Step ) is launched, as that seems to provide exactly this message: https://github.com/jenkinsci/workflow-basic-steps-plugin/blob/master/src/main/java/org/jenkinsci/plugins/workflow/steps/IsUnixStep.java In general it seems the "isUnix" is some API-Implementation as part of the Launcher : https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/Launcher.java I think it boils down to the fact that the docker-workflow-plugin (providing the docker.xyz steps) is using the isUnix Step implementation of the node, and not the isUnix API of the launcher in shell() method like here: https://github.com/jenkinsci/docker-workflow-plugin/blob/master/src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy now, can we do anything here?

          Could the ticket be assigned to the main commiter of the docker-workflow-plugin since jugglefish seems to have found the problem?

           

          Boris Folgmann added a comment - Could the ticket be assigned to the main commiter of the docker-workflow-plugin since jugglefish seems to have found the problem?  

          +1 this is such a noisy useless log message.

          Abram Hemphill added a comment - +1 this is such a noisy useless log message.

          vlatombe is there any chance you can tackle this? Big thx for any feedback

          Peter Niederlag added a comment - vlatombe is there any chance you can tackle this? Big thx for any feedback

          Paul "TBBle" Hampson added a comment - - edited

          It might be possible to reimplement the logic of the core isUnix step directly in Groovy, e.g. something like (untested)

          import hudson.Launcher;
          
          @NonCPS
          private Boolean isUnix() throws Exception {
             // This probably needs to handle "not in a node" better.
             return script.getContext().get(Launcher.class).isUnix();
          }
          

          I don't know if this would require allow-listing an API or not in the script security sandbox.

          This would also be feasible for users like framillien who need the same check in their own code, but it does involve copying code about.

          Better might be if "unixness" could be made a property rather than a function call, like the NODE_NAME env-var for example. That would be a bigger and deeper change though, and take time to flow through the ecosystem.

          Paul "TBBle" Hampson added a comment - - edited It might be possible to reimplement the logic of the core isUnix step directly in Groovy, e.g. something like (untested) import hudson.Launcher; @NonCPS private Boolean isUnix() throws Exception { // This probably needs to handle "not in a node" better. return script.getContext().get(Launcher.class).isUnix(); } I don't know if this would require allow-listing an API or not in the script security sandbox. This would also be feasible for users like framillien who need the same check in their own code, but it does involve copying code about. Better might be if "unixness" could be made a property rather than a function call, like the NODE_NAME env-var for example. That would be a bigger and deeper change though, and take time to flow through the ecosystem.

          Jesse Glick added a comment -

          The simplest workaround is to stop using the docker-workflow plugin, which you probably should anyway.

          Jesse Glick added a comment - The simplest workaround is to stop using the docker-workflow plugin, which you probably should anyway.

          Ernest Marin added a comment - - edited

          You can use the isUnix method from hudson.model.Computer instead:

          def computer = Jenkins.get().getComputer(env.NODE_NAME)
          if (computer.isUnix()) {
          // do what you want here
          }

          But you will need to allow some ScriptApproval signatures

          staticMethod jenkins.model.Jenkins get
          method jenkins.model.Jenkins getComputer java.lang.String
          method hudson.model.Computer isUnix

          Ernest Marin added a comment - - edited You can use the isUnix method from hudson.model.Computer instead: def computer = Jenkins.get().getComputer(env.NODE_NAME) if (computer.isUnix()) { // do what you want here } But you will need to allow some ScriptApproval signatures staticMethod jenkins.model.Jenkins get method jenkins.model.Jenkins getComputer java.lang. String method hudson.model.Computer isUnix

          cc added a comment - - edited
          def isUnix = !(env.OS?.toLowerCase()?.contains('windows') ?: false) 

          cc added a comment - - edited def isUnix = !(env.OS?.toLowerCase()?.contains( 'windows' ) ?: false )

            Unassigned Unassigned
            gabor_mandity Gabor Mandity
            Votes:
            10 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated: