我怎么在Jenkins经营柏树

lc8prwob  于 2023-03-01  发布在  Jenkins
关注(0)|答案(1)|浏览(112)

我在Jenkins中运行cypress时遇到问题。我在脚本的Execute NodeJS脚本部分指定了"cypress run",但收到错误"SyntaxError:意外的标识符"run'"。
语法错误:在模块的wrapSafe(节点:内部/模块/cjs/加载器:1195:20)的内部编译函数(节点:内部/虚拟机:73:18)处出现意外标识符"run"。在模块的Module._extensions..js(节点:内部/模块/cjs/加载器:1329:10)处出现_compile(节点:内部/模块/cjs/加载器:1239:27)。在模块的load(节点:内部/模块/cjs/加载器:1133:32)处出现_load(节点:内部/模块/cjs/加载器:972:12)。在函数的executeUserEntryPoint [as runMain](节点:内部/模块/运行主模块:83:12)处出现意外标识符"run",在节点:内部/主模块/运行主模块:23:47处
Node.js v19.6.1构建步骤"执行NodeJS脚本"将构建标记为失败完成:失效

sqxo8psd

sqxo8psd1#

首先,您需要将测试加载到Jenkins工作区。运行测试的简单Jenkinsfile(此步骤用于将代码从存储库检出到Jenkins工作区:

dir('TESTS') {
git branch: 'main',
url: 'git@YOUR_REPO.git',
credentialsId: 'YOUR_CREDS_ID'
})

之后你就可以启动测试Jenkins应该操作柏树

pipeline {
  agent {
    // this image provides everything needed to run Cypress
    docker {
      image 'cypress/browsers:node-18.14.1-chrome-110.0.5481.96-1-ff-109.0-edge-110.0.1587.41-1'
    }
  }

  stages {
    // first stage installs node dependencies and Cypress binary
    // npm ci - install dependecies for Jenkins
    stage('build') {
      steps {
        echo "Running build ${env.BUILD_ID} on ${env.JENKINS_URL}"
        sh 'npm ci'
        sh 'npm run cy:verify'
      }
    }

    // this stage runs end-to-end tests, and each agent uses the workspace
    // from the previous stage
    stage('cypress tests') {

      // simple command for triggering tests
      // NO_COLOR environment variable to 1 to strip an ANSI color code from the output, and then runs Cypress
      // if need you can provide all params that you need
      steps{
        dir('TESTS') {
            git branch: 'main',
            url: 'git@YOUR_REPO.git',
            credentialsId: 'YOUR_CREDS_ID'
        }
        sh 'NO_COLOR=1 cd TESTS && npm run cypress run'
      }

    }
  }
}

相关问题