I have a react native app building on Azure Devops ok,
now to create the distribution, it shows a grey arrow on the "jobs", and I cannot find the app distributed,
What is Result: False ?
here the yaml
trigger:
- master
pool:
vmImage: 'macOS-10.14'
variables:
- group: AndroidKeystore
steps:
- task: NodeTool#0
displayName: 'Install Node'
inputs:
versionSpec: '12.16.1'
- script: npm install
displayName: 'Install node dependencies'
- script: |
npm i jetifier
npx jetify
displayName: 'npx'
- script: |
rm -r android/app/src/main/res/drawable-*
rm -r android/app/src/main/res/raw
displayName: 'delete before'
- task: Gradle#2
inputs:
workingDirectory: 'android'
gradleWrapperFile: 'android/gradlew'
gradleOptions: '-Xmx3072m'
publishJUnitResults: false
testResultsFiles: '**/TEST-*.xml'
tasks: 'assembleRelease'
- task: AndroidSigning#3
inputs:
apkFiles: '**/*.apk'
apksign: true
apksignerKeystoreFile: 'my-release-key.keystore'
apksignerKeystorePassword: '$(jarsignerKeystorePassword)'
apksignerKeystoreAlias: 'my-key-alias'
apksignerKeyPassword: '$(jarsignerKeyPassword)'
- script: mv android/app/build/outputs/apk/release/app-release.apk ReactNativePipeline$(Build.BuildNumber).apk
displayName: 'Rename apk'
- task: PublishBuildArtifacts#1
inputs:
pathtoPublish: ReactNativePipeline$(Build.BuildNumber).apk
artifactName: drop
publishLocation: 'container'
- task: AppCenterDistribute#3
displayName: "Create a release on App Center"
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
inputs:
serverEndpoint: 'VSAC'
appSlug: 'Wisr/WisrRN-Android2'
appFile: 'ReactNativePipeline$(Build.BuildNumber).apk'
releaseNotesOption: 'input'
releaseNotesInput: |
$(Build.SourceVersionMessage)
latest source: '$(Build.SourceVersion)'
An automated release from Azure DevOps
destinationType: 'groups'
distributionGroupId: 'testBench'
So how to make the build available on the specific group "testBench"
What is Result: False ?
This is the result of condition. From the task log, the Build.SourceBranch is refs/heads/androidPipe.
refs/heads/androidPipe eq refs/heads/master Result: false
In your Yaml sample, the condition settings:
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
This means that when the Build.SourceBranch is master, it will run the AppCenterDistribute task. Or it will not run the task(Skip the task).
Here are two methods to solve this issue:
1.You could change the Condition:
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/androidPipe'))
2.You could use the master branch to run the pipeline. Then the task will execute.
By the way, if you don't need this condition, you can also delete it. In this case, no matter what branch it is, this task will run.
For more detailed information, you could refer to this doc about Condition.
Related
I have an Ionic Capacitor Android app that I need to set up an Azure DevOps yaml pipeline for.
Here's my yaml:
- task: JavaToolInstaller#0
inputs:
versionSpec: "11"
jdkArchitectureOption: "x64"
jdkSourceOption: "PreInstalled"
displayName: "Install JDK v11"
- task: NodeTool#0
inputs:
versionSpec: "16.x"
displayName: "Install Node.js v16.x"
- task: Npm#1
inputs:
workingDir: "$(projectDirectory)"
command: install
displayName: "NPM Install"
- task: Npm#1
inputs:
command: "custom"
workingDir: "$(projectDirectory)"
customCommand: "install -g #ionic/cli"
displayName: "NPM Install Ionic CLI"
- powershell: |
ionic cap build android --no-open
npx cap sync android
workingDirectory: $(projectDirectory)
displayName: "Android: Ionic Cap Build and Sync"
- task: Gradle#3
inputs:
workingDirectory: $(projectDirectory)/android
gradleWrapperFile: "$(projectDirectory)/android/gradlew"
publishJUnitResults: false
tasks: assembleRelease
displayName: "Android: Build APK"
- task: AndroidSigning#3
displayName: "Android: Sign .APK file(s)"
inputs:
apkFiles: "$(projectDirectory)/android/app/build/outputs/apk/$(buildConfiguration)/*.apk"
apksign: true
apksignerKeystoreFile: "$(ts-secure-file-name)"
apksignerKeystorePassword: "$(ts-keystore-password)"
apksignerKeystoreAlias: "$(ts-keystore-alias)"
apksignerKeyPassword: "$(ts-keystore-password)"
zipalign: true # zipalign is no longer needed ? ref: https://stackoverflow.com/a/64973262/1508398
With this, I get the error at Android Signing step saying
Unable to open
'D:\a\1\s\Source\node_modules\webdriver-js-extender\built\built\built\built\built\built\built\built\built\built\built\built\built\built\built\built\spec\comm
##[error]Error: The process 'C:\Android\android-sdk\build-tools\33.0.0\zipalign.exe' failed with
exit code 1
When I set the zipAlign:false, then the signing fails saying:
Exception in thread "main" com.android.apksig.apk.ApkFormatException:
Malformed APK: not a ZIP archive
I am really new to this. Any idea on what I am missing out here?
Basically I have this in my build.gradle:
Like this I can build an APK that can be installed on a device without any error but on Azure I have these lines commented.
In Azure Devops I don't use these values, this part is commented. But I need this part when I generate the APK otherwise it won't run on device.
Currently I use this pipeline to build & sign the apk:
- stage: Android
dependsOn: [ReleaseNotes]
jobs:
- job: AndroidJob
pool:
vmImage: 'ubuntu-latest'
displayName: Android
steps:
- task: FlutterInstall#0
displayName: "Install Flutter SDK"
inputs:
mode: 'auto'
channel: 'stable'
version: 'latest'
- task: FlutterBuild#0
displayName: 'Flutter Build App - Android'
inputs:
target: apk
iosCodesign: false
projectDirectory: $(projectDirectory)
- task: AndroidSigning#3
displayName: 'Signing and aligning APK file(s) **/*.apk'
inputs:
apkFiles: '**/*.apk'
apksign: true
apksignerKeystoreFile: upload-keystore.jks
apksignerKeystorePassword: $(upload-keystore-password)
apksignerKeystoreAlias: upload
apksignerKeyPassword: $(upload-keystore-password)
What could be the solution?
Thanks in advance.
Failed to apply plugin 'com.android.internal.application'.
Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
Your current JDK is located in /Users/runner/hostedtoolcache/Java_Temurin-Hotspot_jdk/8.0.332-9/x64/Contents/Home/jre
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing org.gradle.java.home in gradle.properties.
According to the error message, your project has been set to require Java 11. However, the default Java version installed on the agent machine is Java 8.
In Azure Pipelines, when the default Java version installed on the agent machine is not consistent with that required by your project, you can use the Java Tool Installer task to install the required Java version. This task will install the specified Java version and set it to the JAVA_HOME environment variable on the agent machine.
Then in the subsequent tasks in the same job, the specified Java version will be used by default.
Yea, I was having the same issue on Azure Pipelines with mac-latest.
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/runner/work/1/s/android/app/build.gradle' line: 1
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.android.internal.application'.
> Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
Your current JDK is located in /Users/runner/hostedtoolcache/Java_Temurin-Hotspot_jdk/8.0.352-8/x64/Contents/Home/jre
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing `org.gradle.java.home` in `gradle.properties`.
I used JavaToolInstaller to set JAVA_HOME to 11 and then had to update gradle.properties and set org.gradle.java.home to the value in JAVA_HOME. Hope this helps someone else.
pool:
vmImage: 'macOS-latest'
steps:
- task: NodeTool#0
inputs:
versionSpec: '16.17.1'
displayName: 'Install Node.js'
- task: JavaToolInstaller#0
inputs:
versionSpec: '11'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'
- script: |
npm install
cd android
echo "org.gradle.java.home=$JAVA_HOME" >> ./gradle.properties
displayName: 'Android Setup Script'
- task: Gradle#3
inputs:
workingDirectory: 'android/'
gradleWrapperFile: 'android/gradlew'
gradleOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.8'
jdkArchitectureOption: 'x64'
publishJUnitResults: false
sonarQubeRunAnalysis: false
tasks: 'assembleRelease'
options: '-PversionName=$(Build.BuildNumber) -PversionCode=$(Build.BuildId)'
- task: AndroidSigning#3
inputs:
apkFiles: '**/*.apk'
apksignerKeystoreFile: 'upload.keystore'
apksignerKeystorePassword: '$(AndroidKeyStorePassword)'
apksignerKeystoreAlias: '$(AndroidKeyAlias)'
apksignerKeyPassword: '$(AndroidKeyPassword)'
zipalign: false
trigger:
- CDCI
pool:
vmImage: 'macOS-latest'
steps:
- task: NodeTool#0
inputs:
versionSpec: '16.17.1'
displayName: 'Install Node.js'
# - task: JavaToolInstaller#0
# inputs:
# versionSpec: "8"
# jdkArchitectureOption: x64
# jdkSourceOption: 'PreInstalled'
- task: JavaToolInstaller#0
inputs:
versionSpec: "11"
jdkArchitectureOption: x64
jdkSourceOption: 'PreInstalled'
- script: |
npm install
cd android
echo "org.gradle.java.home=$JAVA_HOME" >> ./gradle.properties
displayName: 'Android Setup Script'
# - script: |
# java -version
# env:
# JAVA_HOME: $(JAVA_HOME_8_X64)
# PATH: $(JAVA_HOME_8_X64)/bin;$(PATH)
# - script: |
# echo "##vso[task.setvariable variable=JAVA_HOME]$(JAVA_HOME_11_X64)"
# echo "##vso[task.setvariable variable=PATH]$(JAVA_HOME_11_X64)\bin;$(PATH)"
# displayName: "Set java version"
# Gradle v1
# Build using a Gradle wrapper script.
- task: Gradle#3
inputs:
workingDirectory: ''
gradleWrapperFile: 'gradlew'
gradleOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '11'
jdkArchitectureOption: 'x64'
publishJUnitResults: false
sonarQubeRunAnalysis: false
tasks: 'assembleRelease'
options: '-PversionName=$(Build.BuildNumber) -PversionCode=$(Build.BuildId)'
# Download secure file
# Download a secure file to the agent machine
- task: DownloadSecureFile#1
inputs:
secureFile: 'keystore.jks'
- task: AndroidSigning#3
inputs:
apkFiles: '**/*.apk'
apksignerKeystoreFile: 'keystore.jks'
apksignerKeystorePassword: '$(jarsignerKeystorePassword)'
apksignerKeystoreAlias: '$(keyAlias)'
apksignerKeyPassword: '$(jarsignerKeyPassword)'
zipalign: false
- task: CopyFiles#2
inputs:
contents: '**/*.apk'
targetFolder: '$(build.artifactStagingDirectory)'
- task: PublishBuildArtifacts#1
- task: CmdLine#2
inputs:
script: 'appcenter login --token c47e589dadcc75a75fc51e211d7144f245da9e8c'
- task: AppCenterDistribute#3
inputs:
serverEndpoint: 'AppCentreServiceConnection'
appSlug: 'tauqeer.majeed-auxilium.digital/AirPortr'
appFile: 'app/release/app-release.apk'
buildVersion: '1.1'
releaseNotesOption: 'file'
releaseNotesFile: 'release-notes.txt'
destinationType: 'groups'
distributionGroupId: '667d2623-9734-4b84-84ce-8deb0e919928'
I am trying to create CI/CD pipeline, for iOS and android, in Azure Devops for a React-Native app.
With the android pipeline, whether I choose to create a yaml or use the classic editor and use pre-configured android tasks, the pipeline always fails on the build task (bundleRelease). The error I receive is:
FAILURE: Build failed with an exception.
Where:
Settings file '/home/vsts/work/1/s/app-rn/android/settings.gradle' line: 12
What went wrong:
A problem occurred evaluating settings 'iEquos'.
Could not read script '/home/vsts/work/1/s/app-rn/node_modules/#react-native-community/cli-platform-android/native_modules.gradle' as it does not exist.
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 12s
Error: The process '/home/vsts/work/1/s/app-rn/android/gradlew' failed with exit code 1
at ExecState._setResult (/home/vsts/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.200.2/node_modules/azure-pipelines-task-lib/toolrunner.js:944:25)
at ExecState.CheckComplete (/home/vsts/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.200.2/node_modules/azure-pipelines-task-lib/toolrunner.js:927:18)
at ChildProcess. (/home/vsts/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.200.2/node_modules/azure-pipelines-task-lib/toolrunner.js:840:19)
at ChildProcess.emit (events.js:198:13)
at maybeClose (internal/child_process.js:982:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
##[error]Error: The process '/home/vsts/work/1/s/app-rn/android/gradlew' failed with exit code 1
Finishing: Gradle
This is line being referred to in android/settings.gradle:
apply from: file("../node_modules/#react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings, "../")
The node modules folder is in the 'app-rn' directory, at the same level as the "android" folder, so only using one "../" is correct?
I can build the android solution locally through a termianl or using Android studio so I am completely clueless to why this is occurring in DevOps.
A similar issue is occurring with my pipeline for iOS. The issue is occurring when istalling Cocoa Pods:
DevOps Install Cocoa Pods Error
Here is an image of my PodFile, located in the 'iOS' folder. The 'iOS' folder is located at the same level as 'node-modules', both inside a folder 'app-rn':
Podfile
Here is the yaml for android:
# Android
# Build your Android project with Gradle.
# Add steps that test, sign, and distribute the APK, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/android
variables:
- group: DriverApp
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
name: $(date:yyyy).$(Month)$(rev:.r)
steps:
- script: yarn install
- task: Gradle#2
inputs:
gradleWrapperFile: 'app-rn/android/gradlew'
workingDirectory: 'app-rn/android/'
options: '-PversionName=$(Build.BuildNumber) -PversionCode=$(Build.BuildId)'
tasks: 'bundleRelease'
publishJUnitResults: false
javaHomeOption: 'JDKVersion'
gradleOptions: '-Xmx3072m'
sonarQubeRunAnalysis: false
- task: AndroidSigning#3
inputs:
apkFiles: '**/*.aab'
apksignerKeystoreFile: 'keystore.jks'
apksignerKeystorePassword: '$(AndroidKeyStorePassword)'
apksignerKeystoreAlias: '$(AndroidKeyAlias)'
apksignerKeyPassword: '$(AndroidKeyAliasPassword)'
zipalign: false
- task: PublishBuildArtifacts#1
inputs:
# PathtoPublish: 'android/app/build/outputs/apk/release'
PathtoPublish: 'android/app/build/outputs/'
ArtifactName: 'drop'
publishLocation: 'Container'
The yaml for iOS:
# trigger:
# branches:
# include:
# - master
variables:
- group: DriverApp
pool:
vmImage: 'macos-latest'
steps:
- checkout: self
persistCredentials: true
clean: true
- task: NodeTool#0
displayName: 'Install Node'
inputs:
versionSpec: '12.19.0' # you can use your desired version here
# workingDirectory: 'app-rn/'
- script: yarn install
displayName: Install Dependencies
- task: InstallAppleCertificate#2
displayName: Install Apple Certificate
inputs:
certSecureFile: 'AppleDistributionCertificate.p12'
certPwd: '$(AppleCertificatePassword)'
keychain: 'temp'
deleteCert: true
- task: InstallAppleProvisioningProfile#1
displayName: 'Install Apple Provisioning Profile'
inputs:
provisioningProfileLocation: 'secureFiles'
provProfileSecureFile: 'iEquos_App_Store.mobileprovision'
removeProfile: true
- task: CocoaPods#0
displayName: 'Install CocoaPods'
inputs:
workingDirectory: 'app-rn/ios'
- task: Xcode#5
displayName: 'Build IPA'
inputs:
actions: 'build'
configuration: 'Release'
sdk: 'iphoneos'
xcWorkspacePath: 'app-rn/ios/iEquos.xcworkspace'
scheme: 'iEquos'
packageApp: true
exportPath: 'output'
signingOption: 'manual'
signingIdentity: '$(APPLE_CERTIFICATE_SIGNING_IDENTITY)'
provisioningProfileUuid: '$(APPLE_PROV_PROFILE_UUID)'
- task: CopyFiles#2
displayName: 'Copy IPA'
inputs:
contents: '**/*.ipa'
targetFolder: '$(build.artifactStagingDirectory)'
overWrite: true
flattenFolders: true
- task: PublishBuildArtifacts#1
displayName: 'Publish IPA to artifacts'
inputs:
PathtoPublish: '$(build.artifactStagingDirectory)'
ArtifactName: 'ios'
publishLocation: 'Container'
I have searched stackoverflow for similar issues, but only seem to find people running into these issues locally, nto within DevOps. As I mentioned before, I can build the android and iOS app locally.
I am fairly new to posting on stack overflow so please let me know if I should provide anymore information.
Any help would be greatly appreciated.
Have you tried this in azure-pipelines.yml file:
- script: /usr/local/bin/pod deintegrate
workingDirectory: 'app-rn/ios'
displayName: 'pod deintegrate'
- script: /usr/local/bin/pod install
workingDirectory: 'app-rn/ios'
displayName: 'pod install'
insted of:
- task: CocoaPods#0
displayName: 'Install CocoaPods'
inputs:
workingDirectory: 'app-rn/ios'
I have a pipeline that ones running perfectly when my application wasn't flavored.
it was building, signing and releasing the application to the firebase distribution.
Now I have the application flavored and I want on each push to development to release the app whether on com.example_flavor1 or com.example_flavor2
the gradle task and the firebase app id should change according to the flavor but i'm not knowing how to do so, can you help please
Here's my pipeline
trigger:
- development
variables:
- group: 'Variables'
stages:
- stage: Build
displayName: Build & Archive
jobs:
- job: build
displayName: build
pool:
vmImage: $(vmImage)
steps:
- task: Gradle#2
inputs:
workingDirectory: ''
gradleWrapperFile: 'gradlew'
gradleOptions: '-Xmx3072m'
jdkVersionOption: '1.8'
jdkArchitectureOption: 'x64'
publishJUnitResults: false
testResultsFiles: '**/TEST-*.xml'
tasks: 'assembleRelease --stacktrace'
- task: DownloadSecureFile#1
displayName: Retrieving the Keystore
inputs:
secureFile: 'keystore.keystore'
- task: AndroidSigning#3
displayName: Signing the Release 2
inputs:
apkFiles: '**/*.apk'
apksign: true
apksignerKeystoreFile: 'keystore.keystore'
apksignerKeystorePassword: '$(KeyStorePassword)'
apksignerKeystoreAlias: '$(KeyAlias)'
apksignerKeyPassword: '$(KeyPassword)'
apksignerArguments: --out $(Build.SourcesDirectory)/app/build/outputs/apk/release/app-$(MajorVersion).$(MinorVersion).$(Build.BuildID)-release.apk
zipalign: false
- task: CopyFiles#2
displayName: Archive APKs
inputs:
contents: '**/*.apk'
targetFolder: '$(build.artifactStagingDirectory)/apk'
- task: CopyFiles#2
displayName: Archive AABs
inputs:
contents: '**/*.aab'
targetFolder: '$(build.artifactStagingDirectory)/aab'
- task: PublishBuildArtifacts#1
displayName: Publish build artifacts
inputs:
pathToPublish: '$(build.artifactStagingDirectory)'
artifactName: '$(MajorVersion).$(MinorVersion).$(Build.BuildID)'
- stage: Publish
displayName: Publish
condition: succeeded()
jobs:
- deployment:
displayName: Firebase Tools install and deploy
pool:
vmImage: $(vmImage)
environment: Dev
strategy:
runOnce:
deploy:
steps:
- task: NodeTool#0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- task: DownloadBuildArtifacts#0
inputs:
buildType: 'current'
artifactName: '$(MajorVersion).$(MinorVersion).$(Build.BuildID)'
downloadPath: '$(System.ArtifactsDirectory)'
- script: |
cd $(Pipeline.Workspace)
npm install -g firebase-tools
firebase appdistribution:distribute $(System.ArtifactsDirectory)/$(MajorVersion).$(MinorVersion).$(Build.BuildID)/apk/app/build/outputs/apk/release/app-$(MajorVersion).$(MinorVersion).$(Build.BuildID)-release.apk --project $(firebase-project-id) --app $(firebase-android-app-id) --token $(firebase-token) --testers "$(firebase-testers-emails)" --groups "$(firebase-testers-groups)" --release-notes "$(release-notes)" --debug
displayName: 'npm install and distribute'
You could implement parallel jobs in Azure Devops to support an arbitrary number of Gradle flavors an Android app. And use Templates to define reusable content, logic, and parameters. For example:
jobs:
- job: A
variables:
- group: "A"
steps:
- template: build.yml
- job: B
variables:
- group: "B"
steps:
- template: build.yml
Here is a simple example you may refer to:
https://github.com/seanKenkeremath/AzureDevopsAndroidFlavorsExample