首页 > 解决方案 > ReactNative 移动应用程序的 CI 管道不起作用

问题描述

我们的团队正在使用 React Native 开发一个移动应用程序。我已从 Azure Repo 获取代码并将其克隆到我的本地系统以构建系统一次,然后再开始为其创建 Azure Pipeline。

我按照开发人员的指示在我的系统中安装了以下内容:节点版本 12.8.3 npm 版本 7.6.1 python 2.7.15 JDK 8.0.2410.7

我已经运行了以下命令来构建 android 源代码:

npm install -g react-native-cli
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

package.json 定义了以下脚本:

"main": "index.js",
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "web": "expo start --web",
    "start": "react-native start",
    "test": "jest"
    }

现在在我的本地系统中构建成功,我正在为 CI 管道创建一个管道。下面是代码:

pool:
  vmImage: ubuntu-latest

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '12.x'
  displayName: 'Install Node.js'

- script: npm install
  displayName: 'Install node dependencies'

- task: Gradle@2
  inputs:
    workingDirectory: '/android'
    gradleWrapperFile: '/android/gradlew'
    gradleOptions: '-Xmx3072m'
    publishJUnitResults: false
    testResultsFiles: '**/TEST-*.xml'
    tasks: 'assembleRelease'

我从我看到的许多例子中学到的是,Gradle 任务将是捆绑和生成 apk 文件。但是我创建的管道抛出错误,如下所示:

A problem occurred evaluating settings 'MobileApp'.
 Could not read script '/home/vsts/work/1/s/MobileApp/node_modules/react-native-unimodules/gradle.groovy' as it does not exist.

这就是我在 settings.gradle 文件中看到的内容:

rootProject.name = 'MobileApp'

apply from: '../node_modules/react-native-unimodules/gradle.groovy'
includeUnimodulesProjects()

apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
applyNativeModulesSettingsGradle(settings)

include ':app'
我觉得完全是多个错误,而不仅仅是设置文件。当我在本地系统中运行构建时,一切正常。但是当我运行管道时,它显示出完整的问题。感谢对此的任何投入。

PS:我最近才开始在 devops 工作。我能够为 Dotnet 服务和 Angular 项目设置管道。但是移动应用程序对我来说很新。

标签: azure-devopsreact-native-androidmobile-application

解决方案


推荐阅读