React-native app build fail

I recently start using jenkins and my first attempt is to build react-native app and upload to the github releases. I guess I setup all the required plugins and environment. When I tried to build the reactnative I run into the problem.

Replayed #1

Obtained Jenkinsfile from e6ecb5376d67442b7f6e093ac53b2c5a531db40d
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins
 in /Users/niranjanshk/.jenkins/workspace/asdfhjkl
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
The recommended git tool is: NONE
using credential Github
 > git rev-parse --resolve-git-dir /Users/niranjanshk/.jenkins/workspace/asdfhjkl/.git # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/niranjanshk27/asdfghj.git # timeout=10
Fetching without tags
Fetching upstream changes from https://github.com/niranjanshk27/asdfghj.git
 > git --version # timeout=10
 > git --version # 'git version 2.39.5 (Apple Git-154)'
using GIT_ASKPASS to set credentials Access to github
 > git fetch --no-tags --force --progress -- https://github.com/niranjanshk27/asdfghj.git +refs/heads/main:refs/remotes/origin/main # timeout=10
Checking out Revision e6ecb5376d67442b7f6e093ac53b2c5a531db40d (main)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f e6ecb5376d67442b7f6e093ac53b2c5a531db40d # timeout=10
Commit message: "update setting"
 > git rev-list --no-walk e6ecb5376d67442b7f6e093ac53b2c5a531db40d # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Prepare)
[Pipeline] echo
Preparing the application
[Pipeline] nodejs
[Pipeline] {
[Pipeline] sh
+ pwd
/Users/niranjanshk/.jenkins/workspace/asdfghjkl
+ yarn install --frozen-lockfile
yarn install v1.22.19
[1/5] Validating package.json...
[2/5] Resolving packages...
success Already up-to-date.
$ patch-package
patch-package 8.0.0
Applying patches...
react-native-snap-carousel@3.9.1 ✔
Done in 1.09s.
++ node -p 'require('\''./package.json'\'').version'
+ appVersion=0.0.1
+ APP_VERSION=0.0.1
+ RELEASE_VERSION=v0.0.1
[Pipeline] }
[Pipeline] // nodejs
[Pipeline] sh
+ pwd
/Users/niranjanshk/.jenkins/workspace/asdfghjkl
+ cd android
+ pwd
/Users/niranjanshk/.jenkins/workspace/asdfghjkl/android
+ ./gradlew clean
> Task :gradle-plugin:settings-plugin:checkKotlinGradlePluginConfigurationErrors
> Task :gradle-plugin:shared:checkKotlinGradlePluginConfigurationErrors
> Task :gradle-plugin:shared:compileKotlin UP-TO-DATE
> Task :gradle-plugin:shared:compileJava NO-SOURCE
> Task :gradle-plugin:shared:processResources NO-SOURCE
> Task :gradle-plugin:shared:classes UP-TO-DATE
> Task :gradle-plugin:shared:jar UP-TO-DATE
> Task :gradle-plugin:settings-plugin:compileKotlin UP-TO-DATE
> Task :gradle-plugin:settings-plugin:compileJava NO-SOURCE
> Task :gradle-plugin:settings-plugin:pluginDescriptors UP-TO-DATE
> Task :gradle-plugin:settings-plugin:processResources UP-TO-DATE
> Task :gradle-plugin:settings-plugin:classes UP-TO-DATE
> Task :gradle-plugin:settings-plugin:jar UP-TO-DATE
> Task :gradle-plugin:react-native-gradle-plugin:checkKotlinGradlePluginConfigurationErrors
> Task :gradle-plugin:react-native-gradle-plugin:pluginDescriptors
> Task :gradle-plugin:react-native-gradle-plugin:processResources
> Task :gradle-plugin:react-native-gradle-plugin:compileKotlin
> Task :gradle-plugin:react-native-gradle-plugin:compileJava NO-SOURCE
> Task :gradle-plugin:react-native-gradle-plugin:classes
> Task :gradle-plugin:react-native-gradle-plugin:jar
> Task :app:clean UP-TO-DATE

BUILD SUCCESSFUL in 4s
14 actionable tasks: 7 executed, 7 up-to-date
+ ./gradlew assembleRelease
> Task :gradle-plugin:settings-plugin:checkKotlinGradlePluginConfigurationErrors
> Task :gradle-plugin:shared:checkKotlinGradlePluginConfigurationErrors
> Task :gradle-plugin:shared:compileKotlin UP-TO-DATE
> Task :gradle-plugin:shared:compileJava NO-SOURCE
> Task :gradle-plugin:shared:processResources NO-SOURCE
> Task :gradle-plugin:shared:classes UP-TO-DATE
> Task :gradle-plugin:shared:jar UP-TO-DATE
> Task :gradle-plugin:settings-plugin:compileKotlin UP-TO-DATE
> Task :gradle-plugin:settings-plugin:compileJava NO-SOURCE
> Task :gradle-plugin:settings-plugin:pluginDescriptors UP-TO-DATE
> Task :gradle-plugin:settings-plugin:processResources UP-TO-DATE
> Task :gradle-plugin:settings-plugin:classes UP-TO-DATE
> Task :gradle-plugin:settings-plugin:jar UP-TO-DATE
> Task :gradle-plugin:react-native-gradle-plugin:checkKotlinGradlePluginConfigurationErrors
> Task :gradle-plugin:react-native-gradle-plugin:compileKotlin UP-TO-DATE
> Task :gradle-plugin:react-native-gradle-plugin:compileJava NO-SOURCE
> Task :gradle-plugin:react-native-gradle-plugin:pluginDescriptors UP-TO-DATE
> Task :gradle-plugin:react-native-gradle-plugin:processResources UP-TO-DATE
> Task :gradle-plugin:react-native-gradle-plugin:classes UP-TO-DATE
> Task :gradle-plugin:react-native-gradle-plugin:jar UP-TO-DATE
> Task :app:buildKotlinToolingMetadata
> Task :app:checkKotlinGradlePluginConfigurationErrors
> Task :app:generateAutolinkingPackageList FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:generateAutolinkingPackageList'.
> RNGP - Autolinking: Could not find project.android.packageName in react-native config output! Could not autolink packages without this field.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 1s
16 actionable tasks: 6 executed, 10 up-to-date
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build)
Stage "Build" skipped due to earlier failure(s)
[Pipeline] getContext
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Deploy)
Stage "Deploy" skipped due to earlier failure(s)
[Pipeline] getContext
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] echo
Always
[Pipeline] cleanWs
[WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Deferred wipeout is disabled by the job configuration...
[WS-CLEANUP] done
[Pipeline] echo
Fail
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1

GitHub has been notified of this commit’s build result

Finished: FAILURE

This app is successfully build locally. Using jenkins ./gradlew clean is successful while running ./gradlew assembleRelease is fail

I might be asking this question in wrong place I’m sorry for that but could anyone guide me what is the issue and possible solution.

The error message seems to indicate that the :app:generateAutolinkingPackageList task failed because it could not find project.android.packageName in the React Native config output. This is a common issue when the React Native configuration is not properly set up or when there are issues with the autolinking process.

Here are some steps that may help troubleshoot and resolve the issue:

  1. Check react-native.config.js
    Make sure that your react-native.config.js file is correctly configured and includes the project.android.packageName field.
  2. Update React Native and Dependencies
    Make sure you are using the latest versions of React Native and its dependencies. Run the following commands to update:
npm install -g react-native-cli
npm install
  1. Jenkins Configuration
    Make sure that Jenkins has the necessary environment variables and paths set up correctly. You can set environment variables in the Jenkins pipeline script.

Here is an example Jenkinsfile that includes steps to set up the environment and build a React Native app:

pipeline {
    agent any

    environment {
        NODE_HOME = '/path/to/node' // Update with your Node.js installation path
        ANDROID_HOME = '/path/to/android/sdk' // Update with your Android SDK path
        PATH = "${env.NODE_HOME}/bin:${env.ANDROID_HOME}/tools:${env.ANDROID_HOME}/platform-tools:${env.PATH}"
    }

    stages {
        stage('Checkout') {
            steps {
                checkout scm
            }
        }
        stage('Install Dependencies') {
            steps {
                sh 'yarn install --frozen-lockfile'
            }
        }
        stage('Clean') {
            steps {
                dir('android') {
                    sh './gradlew clean'
                }
            }
        }
        stage('Build') {
            steps {
                dir('android') {
                    sh './gradlew assembleRelease --stacktrace --info --debug'
                }
            }
        }
    }

    post {
        always {
            cleanWs()
        }
        failure {
            echo 'Build failed'
        }
        success {
            echo 'Build succeeded'
        }
    }
}