Curl 我可以将jest代码覆盖率添加到来自管道的Bitbucket Pull请求中的报告中吗

Curl 我可以将jest代码覆盖率添加到来自管道的Bitbucket Pull请求中的报告中吗,curl,yaml,bitbucket,code-coverage,bitbucket-pipelines,Curl,Yaml,Bitbucket,Code Coverage,Bitbucket Pipelines,我有一个简单的Bitbucket管道配置: image: node:12.16.3 pipelines: pull-requests: '**': - step: caches: - node script: - yarn install - yarn test test脚本从Jest生成代码覆盖率(Jest--coverage) 我试图通过在-纱线测试之后

我有一个简单的Bitbucket管道配置:

image: node:12.16.3

pipelines:
  pull-requests:
    '**':
      - step:
          caches:
            - node
          script:
            - yarn install
            - yarn test
test
脚本从Jest生成代码覆盖率(
Jest--coverage

我试图通过在
-纱线测试
之后添加以下行将此覆盖率数据发送到Reports API(请注意,这是从Bitbuck文档复制的示例代码,我还没有更新它以使其特定于我的数据,因为我想在尝试弄清楚到底需要在数据中做什么之前使配置有效)

-curl——请求放置'https://api.bitbucket.org/2.0/repositories///commit//reports/mySystem-001' \
--标题“内容类型:应用程序/json”\
--数据原始'{
“标题”:“安全扫描报告”,
“详细信息”:“此拉取请求引入了10个新的依赖漏洞。”,
“报告类型”:“安全性”,
“记者”:“我的系统”,
“链接”:http://www.mySystem.com/reports/001",
“结果”:“失败”,
“数据”:[
{
“标题”:“持续时间(秒)”,
“类型”:“持续时间”,
“价值”:14
},
{
“标题”:“是否可以安全合并?”,
“类型”:“布尔值”,
“值”:false
}
]
}'
Bitbucket一直告诉我,我的配置文件无效——即使我直接从他们的文档页面复制了这段代码


是否可以将此代码覆盖率数据发送到Bitbucket Reports API以用于相关的拉取请求?如果是这样的话,我如何制作管道yaml条目?

嘿,请使用这个管道

clone:
  depth: full

definitions:
  caches:
    sonar: ~/.sonar/cache  # Caching SonarCloud artifacts will speed up your build
  steps:
    - step: &sonarcloud
        name: Build, test and analyze on SonarCloud
        caches:
          - node
          - sonar
        script:
          - pipe: sonarsource/sonarcloud-scan:1.2.0
            variables:
              SONAR_TOKEN: ${SONAR_TOKEN}
              EXTRA_ARGS: '-Dsonar.source=src -Dsonar.exclusions=android/**/*,ios/**,node_modules/** -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info'
pipelines:
  pull-requests:
    '**':
      - step:
          image: node:10.15.0
          caches:
            - node
          script:
            - npm install -g yarn
            - yarn install
            - npm run lint
            - npm run test
          artifacts:
            - coverage/**
      - step: *sonarcloud
  branches:
    master:
      - step:
          image: node:10.15.0
          size: 2x
          caches:
            - node
          script:
            - npm install -g yarn
            - yarn install && npx jetify
            - npm run lint
            - npm run test
          artifacts:
            - coverage/**
      - step: *sonarcloud
      - step:
          image: piotrovskyi/react-native-fastlane
          caches:
            - node
          size: 2x
          script:
            - git remote set-url origin $BITBUCKET_GIT_SSH_ORIGIN
            - npm install -g yarn
            - yarn install && npx jetify
            - bundle install
            - npm run bump-patch
            - bundle exec fastlane android _tag
    staging:
      - step:
          image: node:10.15.0
          caches:
            - node
          script:
            - npm install -g yarn
            - yarn install && npx jetify
            - npm run lint
            - npm run test
          artifacts:
            - coverage/**
      - step: *sonarcloud
      - step:
          image: piotrovskyi/react-native-fastlane
          caches:
            - node
          size: 2x
          script:
            - git remote set-url origin $BITBUCKET_GIT_SSH_ORIGIN
            - npm install -g yarn
            - yarn install && npx jetify
            - bundle install
            - npm run bump-patch
            - bundle exec fastlane android generate_apk_prerelease
            - bundle exec fastlane android upload_apk_appcenter_staging token:$APPCENTER_RELEASE_STAGING slackUrl:$SLACK
            - bundle exec fastlane android upload_apk_appcenter_sandbox token:$APPCENTER_RELEASE_SANDBOX slackUrl:$SLACK
    sandbox:
      - step:
          image: node:10.15.0
          caches:
            - node
          script:
            - npm install -g yarn
            - yarn install && npx jetify
            - npm run lint
            - npm run test
          artifacts:
            - coverage/**
      - step: *sonarcloud
      - step:
          image: piotrovskyi/react-native-fastlane
          caches:
            - node
          size: 2x
          script:
            - git remote set-url origin $BITBUCKET_GIT_SSH_ORIGIN
            - npm install -g yarn
            - yarn install && npx jetify
            - bundle install
            - npm run bump-patch
            - bundle exec fastlane android generate_apk_prerelease
            - bundle exec fastlane android upload_apk_appcenter_staging token:$APPCENTER_RELEASE_STAGING slackUrl:$SLACK
            - bundle exec fastlane android upload_apk_appcenter_sandbox token:$APPCENTER_RELEASE_SANDBOX slackUrl:$SLACK

Jest代码覆盖率报告的格式不同,您需要将其转换为以下格式:

{
  "files": [
    {
      "path": "backend/src/app.ts",
      "coverage": "C:51,52;P:53;U:54,55"
    }
  ]
}
您正在使用的API端点似乎也不正确。它应该是插件文档中提到的POST请求:


这到底是什么格式?这是专有格式还是标准格式?
{
  "files": [
    {
      "path": "backend/src/app.ts",
      "coverage": "C:51,52;P:53;U:54,55"
    }
  ]
}