iam*_*bhh 5 git bitbucket reactjs bitbucket-pipelines
我们正在为 React 项目构建一个 bitbucket 管道。我们有预提交挂钩设置,仅对暂存文件进行 linting。如何在 bitbucket 管道中实现相同的目标,当提出拉取请求时,它会获取 diff 文件,并仅检查这些文件的 linting。
如本线程中所述,只要您使用可以在其中安装并运行ESLint 的Docker 节点映像,您就应该能够将其添加到 BitBucket 管道中。
确保您的管道设置为仅在 PR 上运行:
pipelines:
pull-requests:
'**': #this runs as default for any branch not elsewhere defined
- step:
Run Code Online (Sandbox Code Playgroud)
示例:(bitbucket-pipelines.yml根据您的具体项目进行调整)
pipelines:
pull-requests:
'**':
- step:
name: Eslint for pull-request
image: node:12.14
condition:
changesets:
includePaths:
- resources/assets/js/**
script:
- printenv
- CAN_RUN_PIPELINE=$(test -f code_review/eslint/index.js && echo true || echo false)
- if [ "$CAN_RUN_PIPELINE" != true ]; then exit; fi
- git checkout origin/$BITBUCKET_PR_DESTINATION_BRANCH
- git merge origin/$BITBUCKET_BRANCH --no-edit
- git reset $BITBUCKET_PR_DESTINATION_COMMIT
- git add .
- git status
- npm i -g eslint
- npm install --only=dev
- npm install axios dotenv --save-dev
- eslint --format json -c code_review/eslint/rules.js -o ./code_review/eslint/output/output.json --ext .js,.jsx,.vue ./resources || true
- node ./code_review/eslint/index.js $REVIEW_AUTH_STRING
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1770 次 |
| 最近记录: |