2014-08-28 37 views
3

我試圖在Travis-CI上使用PhantomJS運行視覺差異。測試失敗the following error是否可以將文件從TravisCI工作人員的文件系統下載到本地磁盤?

test failed 
    0.188123 distortion 
    Ref: /tmp/tmpaVuhik/tmpg6uSXl/ref_resized 
    Run: /tmp/tmpaVuhik/tmpg6uSXl/screenshot.png 
    Diff: /tmp/tmpaVuhik/tmpg6uSXl/diff.png 

視覺差異已經把有益的預期截圖,實際的截圖和PNG文件上特拉維斯工人一個感性的差異在本地磁盤上。如果我能看到它們,那將是一件好事!

是否可以從Travis工作人員的磁盤下載文件到本地磁盤?

回答

2

您可以使用travis-artifacts上傳運行測試生成的文件。目前它僅支持上傳到Amazon S3。

+0

這似乎是最簡單的一般解決方案。實際上,由於我的構建工件都是圖片,因此我添加了一個--imgur標誌,將它們上載到imgur.com:https://github.com/bslatkin/dpxdt/pull/101 – danvk 2014-09-08 22:20:43

1

您可以將文物scp到您自己的服務器。使用商業travis,他們提供了一個私鑰,您可以使用該私鑰來識別構建(將相應的公鑰添加到目標服務器中的authorized_keys中)。有了travis-ci.org,你可以以一種更加困難的方式來做到這一點。

(開始前,請先閱讀都記錄下來的警告。)

  • 生成公私密鑰對。您將使用它來允許Travis構建自己進行身份驗證並授予其訪問您的服務器的權限。

    ssh-keygen -f build_id_rsa -P '' 
    
  • 將公鑰添加到目標服務器的authorized_keys中。

    $ scp build_id_rsa.pub [email protected]:. 
    [email protected]'s password: 
    build_id_rsa.pub 
    $ ssh [email protected] 
    [...] 
    $ mkdir .ssh 
    $ cat build_id_rsa.pub >>.ssh/authorized_keys 
    $ exit 
    
  • 通過使用ad hoc known_hosts文件登錄來生成known_hosts。當記者問,假設你是幸福的指紋,輸入

    $ ssh -i build_id_rsa -oUserKnownHostsFile=build_known_hosts -oPasswordAuthentication=no [email protected] 
    The authenticity of host [...] can't be established. 
    ECDSA key fingerprint is [...] 
    Are you sure you want to continue connecting (yes/no)? yes 
    Warning: Permanently added 'server,[...]' (ECDSA) to the list of known hosts. 
    Welcome to [...] 
    [email protected]:~$ exit 
    logout 
    Connection to server closed. 
    
  • 如果你現在重複,你可以測試我們已經正確設置鍵和known_host相同的命令。這次它應該沒有任何問題地登錄你,無論是確認還是密碼。

    $ ssh -i build_id_rsa -oUserKnownHostsFile=build_known_hosts -oPasswordAuthentication=no [email protected] 
    Welcome to [...] 
    [email protected]:~$ exit 
    logout 
    Connection to server closed. 
    
  • 現在您需要設置構建。您不能直接使用私鑰,因爲它允許任何人登錄到目標服務器,所以我們會對私鑰進行簡單加密。您可以使用類似

    $ openssl enc -aes-256-cbc -salt -in build_id_rsa -out build_id_rsa.enc 
    enter aes-256-cbc encryption password: 
    Verifying - enter aes-256-cbc encryption password: 
    
  • 添加build_id_rsa.enc和build_known_hosts到項目

  • 添加對稱密碼使用

    travis encrypt 'PASS=yoursymmetricpassword' --add 
    

    的.travis.yml所以你應該得到

    env: 
        global: 
        - secure: [...] 
    

    添加到您的.travis.yml

  • 現在修改您的.travis.yml以上傳文物。

    before_script: 
    - openssl aes-256-cbc -d -pass env:PASS -in build_id_rsa.enc -out build_id_rsa ; chmod 600 build_id_rsa 
    script: 
    - if [[ "$TRAVIS_PULL_REQUEST" == 'false' && "$TRAVIS_BRANCH" == 'master' ]] ; then your_build && scp -q -i build_id_rsa -oPasswordAuthentication=no -oUserKnownHostsFile=build_known_hosts artefact [email protected]:path/ ; else ; your_build ; fi 
    after_script: 
    - rm -rf build_id_rsa 
    

注意事項:請確保您瞭解所有步驟,因爲我可能已經取得了一些錯別字和機制不超安全:包括書寫在生成過程中的特拉維斯虛擬機文件系統私鑰。有許多方法可能出錯,並且該文件可能會暴露,從而訪問您的服務器。

相關問題