2017-09-13 58 views
1

我有一個基於shell的中心任務,在其命令之一中使用半敏感憑據(測試服務器的密鑰)。我想避免這種情況被記錄在任務輸出中。阻止在CI大廳中記錄特定命令

管道的要點是:

jobs: 
- name: foobar 
    plan: 
    <...> 
    - task: build 
    config: 
     platform: linux 
     image_resource: 
     type: docker-image 
     source: 
      repository: ubuntu 
     <...> 
     run: 
     path: bash 
     args: 
     - -exc 
     - | 
      command-which-is-ok-to-print 
      foobar {{my-secret-data}}    # <-- hide this one! 
      another-command-which-is-ok-to-print 

目前的輸出表現爲:

+ command-which-is-ok-to-print 
results of first command which are OK to print 
+ foobar "oh-no-secret-data-here!"     <-- hide this one! 
more results which are OK to print 
+ another-command-which-is-ok-to-print 
even more results which are OK to print 

有沒有辦法來抑制打印這個特定的行?

回答

1

我突然意識到-exc實際上設置標誌ex(我以爲這是短手execute

-x是什麼原因要呼應的命令(通過慶典本身,而不是中央大廳),所以這成功地阻止了正在執行的單個命令:

<...> 
    run: 
    path: bash 
    args: 
    - -exc 
    - | 
     command-which-is-ok-to-print 
     set +x 
     foobar {{my-secret-data}} 
     set -x 
     another-command-which-is-ok-to-print