2017-08-17 40 views
0

我有一個關於超時問題的問題,當我構建自由式作業時,出現以下錯誤。懷疑:TimeOut錯誤Jenkins

我想要做的是使用shell腳本命令行參數運行各種RTT測試。

我的代碼是:

pipeline { 
    agent any 

    stages { 
     stage('Checkout sws-vagrant') { 
      steps { 
       timeout(60) { 
       git branch: 'master_windows', credentialsId: '1d17027a-34b5-4157-93d8-804d0cd56c0a', url: '[email protected]:shipwire/sws-vagrant.git' 
      } 
     } 
    } 

     stage('Vagrant Up Environment Stage') { 
      steps { 
       sh 'vagrant up' 
      } 
     } 

     stage('Vagrant SSH Stage') { 
      steps { 
       sh 'vagrant ssh' 
      } 
     } 

     stage('Redirect to RestTests directory') { 
      steps { 
       sh 'cd /vagrant/src/shipwire/frontend/v2/tests/RestTests/' 
      } 
     } 

     stage('Restart HTTPD Service') { 
      steps { 
       sh 'sudo service httpd restart' 
      } 
     } 

     stage('Run the RTT tests') { 
      steps { 
       sh 'rtt -concurrency=4 test-plans/v3apis/products/products.rtt' 
       } 
      } 
     } 
    } 

作爲管道腳本。

我想要做的是將我的超時設置爲60-300分鐘或MINUTES,就像在管道語法中一樣。

當我建我的工作後,會顯示在控制檯錯誤如下:

我的控制檯錯誤輸出顯示:

Started by user Doga Ozer 
[Pipeline] node 
Running on master in C:\Jenkins\workspace\checkout-vagrant 
[Pipeline] { 
[Pipeline] stage 
[Pipeline] { (Checkout sws-vagrant) 
[Pipeline] timeout 
Timeout set to expire in 1 hr 0 min 
[Pipeline] { 
[Pipeline] git 
> git rev-parse --is-inside-work-tree # timeout=10 
Fetching changes from the remote Git repository 
> git config remote.origin.url [email protected]:shipwire/sws-vagrant.git # timeout=10 
Fetching upstream changes from [email protected]:shipwire/sws-vagrant.git 
> git --version # timeout=10 
using GIT_SSH to set credentials Shipwire Bitbucket Private Key 2 
> git fetch --tags --progress [email protected]:shipwire/sws-vagrant.git +refs/heads/*:refs/remotes/origin/* 
ERROR: Timeout after 10 minutes 
ERROR: Error fetching remote repo 'origin' 
hudson.plugins.git.GitException: Failed to fetch from [email protected]:shipwire/sws-vagrant.git 
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:812) 
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1079) 
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1110) 
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:113) 
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:85) 
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:75) 
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47) 
    at hudson.security.ACL.impersonate(ACL.java:260) 
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44) 
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) 
    at java.util.concurrent.FutureTask.run(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
    at java.lang.Thread.run(Unknown Source) 
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress [email protected]:shipwire/sws-vagrant.git +refs/heads/*:refs/remotes/origin/*" returned status code -1: 
stdout: 
stderr: remote: Counting objects: 2444   
remote: Counting objects: 6663, done.   
remote: Compressing objects: 0% (1/2841)   
remote: Compressing objects: 1% (29/2841)   

Receiving objects: 97% (6498/6663), 346.40 MiB | 366.00 KiB/s 

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1903) 
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1622) 
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:71) 
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:348) 
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:810) 
    ... 13 more 
[Pipeline] } 
[Pipeline] // timeout 
[Pipeline] } 
[Pipeline] // stage 
[Pipeline] stage 
[Pipeline] { (Vagrant Up Environment Stage) 
Stage 'Vagrant Up Environment Stage' skipped due to earlier failure(s) 
[Pipeline] } 
[Pipeline] // stage 
[Pipeline] stage 
[Pipeline] { (Vagrant SSH Stage) 
Stage 'Vagrant SSH Stage' skipped due to earlier failure(s) 
[Pipeline] } 
[Pipeline] // stage 
[Pipeline] stage 
[Pipeline] { (Redirect to RestTests directory) 
Stage 'Redirect to RestTests directory' skipped due to earlier failure(s) 
[Pipeline] } 
[Pipeline] // stage 
[Pipeline] stage 
[Pipeline] { (Restart HTTPD Service) 
Stage 'Restart HTTPD Service' skipped due to earlier failure(s) 
[Pipeline] } 
[Pipeline] // stage 
[Pipeline] stage 
[Pipeline] { (Run the RTT tests) 
Stage 'Run the RTT tests' skipped due to earlier failure(s) 
[Pipeline] } 
[Pipeline] // stage 
[Pipeline] } 
[Pipeline] // node 
[Pipeline] End of Pipeline 
ERROR: Error fetching remote repo 'origin' 
Finished: FAILURE 

回答

1

超時命令超時(60){//你的命令}你使用的是沒有被考慮和使用的默認值,這是。

相反,有兩種方法,

  1. 可以覆蓋從其他行爲的超時SCM部分,在那裏你可以指定超時爲所需的值。在我的情況下,它設置爲解決了這個問題。
  2. 你可以幫助管道語法生成管道腳本檢出項目。下面是爲我工作示例代碼段,你可以調整它按你的方便:

    `stage('Checkout sws-vagrant') { 
        steps { 
         checkout([$class: 'GitSCM', branches: [[name: 'BRANCH_NAME']], browser: [$class: 'GitBlitRepositoryBrowser', projectName: 'PROJECT_NAME', repoUrl: 'REPO_URL (for ex: github.com)'], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false, timeout: 30]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'CREDENTIALS_ID', url: 'URL']]]) 
    
    }` 
    

希望它能幫助:)