Giter Club home page Giter Club logo

Comments (5)

joscha avatar joscha commented on September 1, 2024

This is not specific to shellcheck but to any docker image - just in case you want to suggest using https://github.com/buildkite-plugins/shellcheck-buildkite-plugin for this particular problem: it also can't redirect the output and shellcheck doesn't have a first-class --out my.file flag either.

from docker-buildkite-plugin.

lox avatar lox commented on September 1, 2024

I reckon this is probably outside the scope of what the docker plugin is supposed to do 🤔

I'd be happy to add support to the shellcheck plugin to write to a file? Alternately, perhaps it's easier to just call docker directly in a shellscript for this usecase?

from docker-buildkite-plugin.

joscha avatar joscha commented on September 1, 2024

I can definitely write a wrapper or something, but I think output redirection would be a responsibility of the plugin?

from docker-buildkite-plugin.

toote avatar toote commented on September 1, 2024

From what I can see, this would be expected (albeit quite annoying) behaviour.

The command docker run ... image arg1 arg2 arg3 > output_file would redirect the output of the docker command, not what is run inside of the container itself. As you are clearly specifying that the redirection character is part of the docker command, it needs to be escaped or it wouldn't be passed on to the command running in the container... which will error out or ignore it. This is mostly because output redirection is a feature of terminal shells, not docker nor the programs run in them.

The way to workaround this issue is to use a shell as the command being executed. For example:

- label: ':bash: Lint: SH'
    command: ''
    artifact_paths:
      - web/target/shellcheck-*.xml
    plugins:
      - 'docker#v3.3.0':
          image: 'koalaman/shellcheck:v0.7.0'
          command:
            - '/bin/sh'
            - '-c'
            - 'shellcheck -x a.sh --format checkstyle > web/target/shellcheck-42820572-83ee-4588-abf2-4f761754dba9.xml'

Which is exactly what happens when you specify the command to be run through the step's command instead of the plugin's command option:

- label: ':bash: Lint: SH'
    command: 'shellcheck -x a.sh --format checkstyle > web/target/shellcheck-42820572-83ee-4588-abf2-4f761754dba9.xml'
    artifact_paths:
      - web/target/shellcheck-*.xml
    plugins:
      - 'docker#v3.3.0':
          image: 'koalaman/shellcheck:v0.7.0'

Note that this assumes that the image you are using is not forcing a particular executable through entrypoints (in which case you may have to override it)

from docker-buildkite-plugin.

toote avatar toote commented on September 1, 2024

I believe there is nothing wrong with the plugin so I am closing this issue. Feel free to reply if you think it shouldn't have and we'll re-open it and continue the discussion

from docker-buildkite-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.