• Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • pipeline

      At least within a block step, it should be possible to set something like a ConsoleLogFilter to decorate the output written to TaskListener. Possible use cases:

      • Replacement for decorateLogger in SimpleBuildWrapper.
      • Ability to mask passwords from BindingStep in credentials-binding (unless there is an equivalent to getSensitiveBuildVariables moved up to Run).

          [JENKINS-27392] API to decorate console output

          Jesse Glick added a comment - - edited

          Suggested API: reuse ConsoleLogFilter (passing null for the AbstractBuild argument and requiring implementations to be Serializable), where you can pass this in to BodyInvoker.withContexts (first checking for an instance in your own context to delegate to).

          OutputStream SimpleBuildWrapper.decorateLogger(AbstractBuild, OutputStream) could then be made to delegate to a new method ConsoleLogFilter SimpleBuildWrapper.createDecorator(Run<?,?> build) if the API were copied into core, and CoreWrapperStep (PR 37) needs to call that.

          Jesse Glick added a comment - - edited Suggested API: reuse ConsoleLogFilter (passing null for the AbstractBuild argument and requiring implementations to be Serializable ), where you can pass this in to BodyInvoker.withContexts (first checking for an instance in your own context to delegate to). OutputStream SimpleBuildWrapper.decorateLogger(AbstractBuild, OutputStream) could then be made to delegate to a new method ConsoleLogFilter SimpleBuildWrapper.createDecorator(Run<?,?> build) if the API were copied into core, and CoreWrapperStep (PR 37) needs to call that.

          Tom FENNELLY added a comment - - edited

          Just stashing something I experimented with for this last week (before this JIRA was created). Not based on TaskListener, but instead filtering the logs inside a block based on an Action. We'll more than likely throw this away but just wanted to attach in case.

          https://github.com/tfennelly/workflow-plugin/tree/mask-log-entries (link to the branch - press "Compare" etc if you want)

          (totally incomplete and only kinda works)

          Tom FENNELLY added a comment - - edited Just stashing something I experimented with for this last week (before this JIRA was created). Not based on TaskListener, but instead filtering the logs inside a block based on an Action. We'll more than likely throw this away but just wanted to attach in case. https://github.com/tfennelly/workflow-plugin/tree/mask-log-entries (link to the branch - press "Compare" etc if you want) (totally incomplete and only kinda works)

          Code changed in jenkins
          User: Jesse Glick
          Path:
          step-api/src/main/java/org/jenkinsci/plugins/workflow/steps/BodyInvoker.java
          support/src/main/java/org/jenkinsci/plugins/workflow/support/DefaultStepContext.java
          http://jenkins-ci.org/commit/workflow-plugin/38cd1ea642bd45e45331e89c8cef7ffb8e3740fa
          Log:
          [FIXED JENKINS-27392] Handling ConsoleLogFilter.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: step-api/src/main/java/org/jenkinsci/plugins/workflow/steps/BodyInvoker.java support/src/main/java/org/jenkinsci/plugins/workflow/support/DefaultStepContext.java http://jenkins-ci.org/commit/workflow-plugin/38cd1ea642bd45e45331e89c8cef7ffb8e3740fa Log: [FIXED JENKINS-27392] Handling ConsoleLogFilter.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          step-api/src/main/java/org/jenkinsci/plugins/workflow/steps/BodyInvoker.java
          support/src/main/java/org/jenkinsci/plugins/workflow/support/DefaultStepContext.java
          http://jenkins-ci.org/commit/workflow-plugin/16eb0143aa3f04e5e89eab55ca60101b98b9b449
          Log:
          Merge pull request #107 from jglick/ConsoleLogFilter-JENKINS-27392

          JENKINS-27392 ConsoleLogFilter

          Compare: https://github.com/jenkinsci/workflow-plugin/compare/d60edde46f20...16eb0143aa3f

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: step-api/src/main/java/org/jenkinsci/plugins/workflow/steps/BodyInvoker.java support/src/main/java/org/jenkinsci/plugins/workflow/support/DefaultStepContext.java http://jenkins-ci.org/commit/workflow-plugin/16eb0143aa3f04e5e89eab55ca60101b98b9b449 Log: Merge pull request #107 from jglick/ConsoleLogFilter- JENKINS-27392 JENKINS-27392 ConsoleLogFilter Compare: https://github.com/jenkinsci/workflow-plugin/compare/d60edde46f20...16eb0143aa3f

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: COMPATIBILITY.md http://jenkins-ci.org/commit/workflow-plugin/e6715815daefaf4be79b3a8d68a7a5fe23b21fba Log: JENKINS-27392 Noting. https://github.com/jenkinsci/mask-passwords-plugin/pull/3

          Code changed in jenkins
          User: Jesse Glick
          Path:
          core/src/main/java/jenkins/tasks/SimpleBuildWrapper.java
          test/src/test/java/jenkins/tasks/SimpleBuildWrapperTest.java
          http://jenkins-ci.org/commit/jenkins/a52d665180a7b11dcd64673c3f08b719f6c9f908
          Log:
          JENKINS-27392 SimpleBuildWrapper.createLoggerDecorator

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: core/src/main/java/jenkins/tasks/SimpleBuildWrapper.java test/src/test/java/jenkins/tasks/SimpleBuildWrapperTest.java http://jenkins-ci.org/commit/jenkins/a52d665180a7b11dcd64673c3f08b719f6c9f908 Log: JENKINS-27392 SimpleBuildWrapper.createLoggerDecorator

          Code changed in jenkins
          User: Jesse Glick
          Path:
          core/src/main/java/jenkins/tasks/SimpleBuildWrapper.java
          test/src/test/java/jenkins/tasks/SimpleBuildWrapperTest.java
          http://jenkins-ci.org/commit/jenkins/61b3fb9483f03bcb614ee43835c21cf39afcdf23
          Log:
          Merge pull request #1634 from jglick/SimpleBuildWrapper-JENKINS-27392

          JENKINS-27392 SimpleBuildWrapper.createLoggerDecorator

          Compare: https://github.com/jenkinsci/jenkins/compare/2020bbd5137d...61b3fb9483f0

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: core/src/main/java/jenkins/tasks/SimpleBuildWrapper.java test/src/test/java/jenkins/tasks/SimpleBuildWrapperTest.java http://jenkins-ci.org/commit/jenkins/61b3fb9483f03bcb614ee43835c21cf39afcdf23 Log: Merge pull request #1634 from jglick/SimpleBuildWrapper- JENKINS-27392 JENKINS-27392 SimpleBuildWrapper.createLoggerDecorator Compare: https://github.com/jenkinsci/jenkins/compare/2020bbd5137d...61b3fb9483f0

          dogfood added a comment -

          Integrated in jenkins_main_trunk #4059

          Result = SUCCESS

          dogfood added a comment - Integrated in jenkins_main_trunk #4059 Result = SUCCESS

          Code changed in jenkins
          User: Jesse Glick
          Path:
          aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/CoreWrapperStepTest.java
          http://jenkins-ci.org/commit/workflow-plugin/4ad6605229b6f248fa06c8d9be9bd8bcdb547f80
          Log:
          JENKINS-27392 Prepared test for SimpleBuildWrapper.createLoggerDecorator.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/CoreWrapperStepTest.java http://jenkins-ci.org/commit/workflow-plugin/4ad6605229b6f248fa06c8d9be9bd8bcdb547f80 Log: JENKINS-27392 Prepared test for SimpleBuildWrapper.createLoggerDecorator.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/CoreWrapperStepTest.java
          basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/CoreWrapperStep.java
          pom.xml
          http://jenkins-ci.org/commit/workflow-plugin/874c4618f43316e096562499f0f6a3636951919a
          Log:
          JENKINS-27392 Using SimpleBuildWrapper.createLoggerDecorator from CoreWrapperStep.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/CoreWrapperStepTest.java basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/CoreWrapperStep.java pom.xml http://jenkins-ci.org/commit/workflow-plugin/874c4618f43316e096562499f0f6a3636951919a Log: JENKINS-27392 Using SimpleBuildWrapper.createLoggerDecorator from CoreWrapperStep.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          pom.xml
          src/main/java/com/michelin/cio/hudson/plugins/maskpasswords/MaskPasswordsBuildWrapper.java
          src/main/java/com/michelin/cio/hudson/plugins/passwordparam/PasswordParameterValue.java
          src/test/java/com/michelin/cio/hudson/plugins/maskpasswords/MaskPasswordsWorkflowTest.java
          http://jenkins-ci.org/commit/mask-passwords-plugin/453e8b54b64ad2b54335b1f4265fd90e33d8bf2e
          Log:
          JENKINS-27392 Implement SimpleBuildWrapper in order to support Workflow project type .

          This pull request integrates https://github.com/jenkinsci/mask-passwords-plugin/pull/3

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: pom.xml src/main/java/com/michelin/cio/hudson/plugins/maskpasswords/MaskPasswordsBuildWrapper.java src/main/java/com/michelin/cio/hudson/plugins/passwordparam/PasswordParameterValue.java src/test/java/com/michelin/cio/hudson/plugins/maskpasswords/MaskPasswordsWorkflowTest.java http://jenkins-ci.org/commit/mask-passwords-plugin/453e8b54b64ad2b54335b1f4265fd90e33d8bf2e Log: JENKINS-27392 Implement SimpleBuildWrapper in order to support Workflow project type . This pull request integrates https://github.com/jenkinsci/mask-passwords-plugin/pull/3

          Code changed in jenkins
          User: Oleg Nenashev
          Path:
          COMPATIBILITY.md
          http://jenkins-ci.org/commit/workflow-plugin/8ae0c5d4c33362e7b82a9a39e10b0073eb17f5a7
          Log:
          JENKINS-27392 - Noting Workflow support in Mask Passwords 2.8

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oleg Nenashev Path: COMPATIBILITY.md http://jenkins-ci.org/commit/workflow-plugin/8ae0c5d4c33362e7b82a9a39e10b0073eb17f5a7 Log: JENKINS-27392 - Noting Workflow support in Mask Passwords 2.8

          Code changed in jenkins
          User: Jesse Glick
          Path:
          support/src/main/java/org/jenkinsci/plugins/workflow/support/DefaultStepContext.java
          http://jenkins-ci.org/commit/workflow-support-plugin/e3bea833905716718ed37ef55c5eb5298c21ec3f
          Log:
          [FIXED JENKINS-27392] Handling ConsoleLogFilter.
          Originally-Committed-As: 38cd1ea642bd45e45331e89c8cef7ffb8e3740fa

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: support/src/main/java/org/jenkinsci/plugins/workflow/support/DefaultStepContext.java http://jenkins-ci.org/commit/workflow-support-plugin/e3bea833905716718ed37ef55c5eb5298c21ec3f Log: [FIXED JENKINS-27392] Handling ConsoleLogFilter. Originally-Committed-As: 38cd1ea642bd45e45331e89c8cef7ffb8e3740fa

          Code changed in jenkins
          User: Jesse Glick
          Path:
          aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/CoreWrapperStepTest.java
          http://jenkins-ci.org/commit/workflow-basic-steps-plugin/16c2ccf3948b2f5e1ad0c0ab72556cc4da070db2
          Log:
          JENKINS-27392 Prepared test for SimpleBuildWrapper.createLoggerDecorator.
          Originally-Committed-As: 4ad6605229b6f248fa06c8d9be9bd8bcdb547f80

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/CoreWrapperStepTest.java http://jenkins-ci.org/commit/workflow-basic-steps-plugin/16c2ccf3948b2f5e1ad0c0ab72556cc4da070db2 Log: JENKINS-27392 Prepared test for SimpleBuildWrapper.createLoggerDecorator. Originally-Committed-As: 4ad6605229b6f248fa06c8d9be9bd8bcdb547f80

          Code changed in jenkins
          User: Jesse Glick
          Path:
          aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/CoreWrapperStepTest.java
          basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/CoreWrapperStep.java
          http://jenkins-ci.org/commit/workflow-basic-steps-plugin/60cb60720b2ed1ab64ecaeb72c8c8649dec998b6
          Log:
          JENKINS-27392 Using SimpleBuildWrapper.createLoggerDecorator from CoreWrapperStep.
          Originally-Committed-As: 874c4618f43316e096562499f0f6a3636951919a

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/CoreWrapperStepTest.java basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/CoreWrapperStep.java http://jenkins-ci.org/commit/workflow-basic-steps-plugin/60cb60720b2ed1ab64ecaeb72c8c8649dec998b6 Log: JENKINS-27392 Using SimpleBuildWrapper.createLoggerDecorator from CoreWrapperStep. Originally-Committed-As: 874c4618f43316e096562499f0f6a3636951919a

          Jeffrey Nelson added a comment - - edited

          I am trying to use this wrapper with the cloudbees workflow/pipeline plugin. Refer to the following code snippet:

          node {
              stage 'Test It'
              
              wrap([$class: 'MaskPasswordsBuildWrapper']) {
                  sh '''if [ "$MARATHON_PASSWORD" -eq "theMarathonPassword" ]; then
                            echo it works!
                         fi'''
              }
          }

          I have a global password setup named: MARATHON_PASSWORD with value: theMarathonPassword. However, running this pipeline job results in output:

          Entering stage Test It
          Proceeding
          [Pipeline] stage (Test It)
          [Pipeline] General Build Wrapper : Start
          [Pipeline] wrap {
          [Pipeline] sh
          [AAA-TestPipeline] Running shell script
          + '[' '' -eq ******** ']'
          /apps/jenkins/slave1/workspace/CWL/AAA-TestPipeline/.jenkins-4173bdf1/script.sh: line 2: [: : integer expression expected
          [Pipeline] } //wrap
          [Pipeline] General Build Wrapper : End
          [Pipeline] } //node
          [Pipeline] Allocate node : End
          [Pipeline] End of Pipeline
          Finished: SUCCESS

          In other words, the masking part is working, but accessing the global passwords is not. Am I missing something, or is this a bug?

          Jeffrey Nelson added a comment - - edited I am trying to use this wrapper with the cloudbees workflow/pipeline plugin. Refer to the following code snippet: node { stage 'Test It' wrap([$class: 'MaskPasswordsBuildWrapper' ]) { sh ''' if [ "$MARATHON_PASSWORD" -eq "theMarathonPassword" ]; then echo it works! fi''' } } I have a global password setup named: MARATHON_PASSWORD with value: theMarathonPassword. However, running this pipeline job results in output: Entering stage Test It Proceeding [Pipeline] stage (Test It) [Pipeline] General Build Wrapper : Start [Pipeline] wrap { [Pipeline] sh [AAA-TestPipeline] Running shell script + '[' '' -eq ******** ' ]' /apps/jenkins/slave1/workspace/CWL/AAA-TestPipeline/.jenkins-4173bdf1/script.sh: line 2: [: : integer expression expected [Pipeline] } //wrap [Pipeline] General Build Wrapper : End [Pipeline] } //node [Pipeline] Allocate node : End [Pipeline] End of Pipeline Finished: SUCCESS In other words, the masking part is working, but accessing the global passwords is not. Am I missing something, or is this a bug?

          Sam Gleske added a comment -

          I encounter the same bug.

          Sam Gleske added a comment - I encounter the same bug.

          Same issue here =(
          Is there a way to access global passwords set with Mask Passwords plugin?

          George Yermulnik added a comment - Same issue here =( Is there a way to access global passwords set with Mask Passwords plugin?

            jglick Jesse Glick
            jglick Jesse Glick
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: