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

Option for shell script builder to run as +x

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Component/s: core
    • Labels:
    • Similar Issues:

      Description

      Often you do not want each command in a shell script to be echoed to the console log. There may be a lot of commands, including ones which just set an environment variable; expansions and loops can be confusing; or some commands may include private information such as passwords which should not be displayed.

      You can already prefix your script text with

      set +x
      

      which does the job, but this command is echoed which is annoying, and unless you are experienced with shell scripting you may never have heard of this builtin (or may need to refer to sh.1 to remember the syntax).

      Would be nicer to just have a checkbox available for the shell script builder which would control whether to echo commands or not. Default on (-x) as now. If off, simply do not pass -x to sh.

        Attachments

          Activity

          Hide
          danielbeck Daniel Beck added a comment -

          Similar issue with batch and `@echo off`.

          The question is whether the built-in build steps should support options at all. So far, they have none.

          Show
          danielbeck Daniel Beck added a comment - Similar issue with batch and `@echo off`. The question is whether the built-in build steps should support options at all. So far, they have none.
          Hide
          sag47 Sam Gleske added a comment - - edited

          Prepend your script with a shebang. Then it will behave as you expect in bash. For batch I couldn't tell you. e.g.

          #!/bin/bash
          some script
          

          This allows you to do fancy stuff with your scripts to set up the environment before executing the build. e.g.

          #!/bin/bash -l
          export PS4='$ '
          echo -n "Hostname: "
          hostname
          echo -n "Distro: "
          head -n1 /etc/issue
          echo -n "Kernel: "
          uname -rms
          echo -n "Bash: "
          bash --version | head -n1
          #BUILD_RANDOM will stay consistent throughout the build.  Use the ${RANDOM} variable if you need constantly changing randoms.
          export BUILD_RANDOM="${RANDOM}"
          echo "BUILD_RANDOM: ${BUILD_RANDOM}"
          set -axeE
          
          some build script
          
          Show
          sag47 Sam Gleske added a comment - - edited Prepend your script with a shebang. Then it will behave as you expect in bash. For batch I couldn't tell you. e.g. #!/bin/bash some script This allows you to do fancy stuff with your scripts to set up the environment before executing the build. e.g. #!/bin/bash -l export PS4= '$ ' echo -n "Hostname: " hostname echo -n "Distro: " head -n1 /etc/issue echo -n "Kernel: " uname -rms echo -n "Bash: " bash --version | head -n1 #BUILD_RANDOM will stay consistent throughout the build. Use the ${RANDOM} variable if you need constantly changing randoms. export BUILD_RANDOM= "${RANDOM}" echo "BUILD_RANDOM: ${BUILD_RANDOM}" set -axeE some build script

            People

            • Assignee:
              Unassigned
              Reporter:
              jglick Jesse Glick
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: