Jenkins doesn't recognize IONIC as command - android

I'm currently setting up Jenkins for a IONIC Project of mine.
I've got a Jenkinsfile with the following content:
pipeline {
agent any
stages {
stage ('NPM Setup'){
steps{
bat 'npm install'
}
}
stage('Android Build'){
steps{
bat 'ionic cordova build android --release'
}
}
}
}
Jenkins causes an Error with the following Errormessage:
The "ionic" command is either misspelled or could not be found.
What am i doing wrong here or is there anything i didn't configure for it to run?
The code is stored in a git-repo if this is anything interesting.
Kind regards
Crooky

add ionic cli to your package.json dependencies.
use npx. This command line is bundled with node since version 5.2.0
stage('Android Build'){
steps{
bat 'npx ionic cordova build android --release'
}
}

Related

React Native Navigation React Native CLI Autolinking error

Issue Description
I installed the library via npx react-native link react-native-navigation (and modifying the minSdkVersion in andoid/build.gradle).
When I run npx react-native run-android, the app is built and works fine, though I get the following error in the terminal:
error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually:
- react-native-navigation (to unlink run: "react-native unlink react-native-navigation")
Since the lib has been linked manually, I add an entry in the react-native.config.js file to prevent react native to try to autolink the lib, as in:
module.exports = {
dependencies: {
'react-native-navigation': {
platforms: {
android: null, // disable Android platform, other platforms will still autolink if provided
},
}
}
};
Now, the CLI error is not longer shown and the app is successfully built, but I get an error in the emulator:
TypeError: null is not an object (evaluating "this.nativeCommandsModule.setRoot()").
Which comes about at my first Navigation.setRoot(...); call:
[index.js]
const start = () => {
Navigation.events().registerAppLaunchedListener(() => {
registerScreens();
gotoInitialising();
// gotoLogin();
});
};
start();
My question is, what extra step should I take to get the lib to work and to not have a React Native CLI error, at the same time.
Environment
React Native Navigation version: 6.0.1
React Native version: 0.61.5
Platform(s) (iOS, Android, or both?): Android
Device info (Simulator/Device? OS version? Debug/Release?): Android emulator API 28 - (emulator version 29.2.1-5889189) - Debug build
FYI, since react-native-navigation#6.1.0, the link script has been fixed to update the minSDK for android as well.
Also you should not add react-native-navigation in react-native.config.js as the RNN library is required to be used in your native code. The team has updated the documentation to make the installation guide clearer: https://wix.github.io/react-native-navigation/docs/installing. If you follow the guide, it should be quite straightforward.
run the following command: react-native unlink react-native-navigation

Expo v27/v28 Android App with websocket is crashing

Environment: Android 6 Marshmallow and iOS(all versions)
Error: Android app with WebSockets is crashing with error:
WebSocketModule.close got 1 arguments, expected 3.
The error happens when I close the WebSocket connection just on Android, for instance:
this.ws = new WebSocket(url);
this.ws.onopen = () => {
const command = { command: 'JOIN', room: roonHash };
this.ws.send(JSON.stringify(command));
};
this.ws.onmessage = e => {
//more code here
};
// Finally:
this.ws.close();
iOS:
On iOS it works fine.
I'm using Expo v27 but I got the same error on v28.
Is there any workaround fixing that until the Expo/React Native team fixes it forever?
Expo v27
Update your React Native/Expo v27.0.0 to v27.0.2 on your package.json
Expo v28
Update your React Native/Expo v28.0.0 to v28.0.1 on your package.json
Procedures:
1) Go to your package.json file and change the version of your expo, for example:
From:
"react-native": "https://github.com/expo/react-native/archive/sdk-27.0.0.tar.gz",
To:
"react-native": "https://github.com/expo/react-native/archive/sdk-27.0.2.tar.gz",
2) Delete your node_modules:
$ rm -rf node_modules
3) Install it again:
$ yarn install

cordova build android error : The system cannot find the path specified. Error: cmd: Command failed with exit code 1

I am very new to Ionic2 app development and am trying to build an Android app with it. I want to run the app in Visual Studio emulator and am getting the below error while running 'cordova build android' command.
Please help with it!
Thanks in advance!
**C:\Devlopment ionic\sample\sampleapp>cordova build android
ANDROID_HOME=C:\Users\d.dutta.chowdhury\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_131
The system cannot find the path specified.
Error: cmd: Command failed with exit code 1**
just downgrade your android version to 5
cordova platform rm android
then
cordova platform add android#~5
it worked for me.
I got the same issue and used this command to build project to display entire log with which it is failing,
cordova build -d
it will show gradle path ,sdk path being used to run.
In my case, gradle path was not present.
Running this script worked for me
https://github.com/erobertson42/cordova-plugin-xapkreader/blob/cordova-9/scripts/before_install.js
Here's the code.
You'll have to run npm i fs-extra q
let fse = require('fs-extra');
let q = require('q');
module.exports = function(context) {
const deferral = q.defer();
let target = 'platforms/android/cordova/lib/plugin-build.gradle';
console.log('scripts/before_install: fixing gradle');
fse.readFile(target, 'utf8').then((data) => {
// replace deprecated "compile" configurations with "implementation"
data = data.replace(/debugCompile (project\(.*)\,.*(\))\n\s*releaseCompile.*/g, 'implementation $1)');
// replace old Java 1_6 variables with 1_8
data = data.replace(/(JavaVersion\.VERSION_1)_6/g, '$1_8');
// fix "cdvCompileSdkVersion" and "cdvBuildToolsVersion" undefined variables
data = data.replace(/\/\/ GENERATED FILE! DO NOT EDIT!/, match => `${match}
ext {
apply from: '../../CordovaLib/cordova.gradle'
cdvCompileSdkVersion = privateHelpers.getProjectTarget()
cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools()
}
`);
return fse.writeFile(target, data, 'utf8').then(() => {
console.log('scripts/before_install: done!');
deferral.resolve();
});
}).catch((e) => {
deferral.reject('scripts/before_install: error ' + e);
});
return deferral.promise;
};

Ionic v2 create project issue

I'm trying to get ionic2 up and running by following the Getting Started page. I ran the npm -g install cordova ionic command in step one and everything seemed fine but when I ran step two ionic start --v2 myApp tabs I received errors.
CCasadMBP:Sites ccasad$ ionic start --v2 myAppv2 tabs
/Users/ccasad/.npm-packages/lib/node_modules/ionic/node_modules/ionic-app-lib/lib/start_wizard.js:94
ps.stdout.on('data', (data) => {
^^
SyntaxError: Unexpected token =>
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.start_wizard (/Users/ccasad/.npm-packages/lib/node_modules/ionic/node_modules/ionic-app-lib/index.js:25:12)
at Object.<anonymous> (/Users/ccasad/.npm-packages/lib/node_modules/ionic/lib/ionic/start.js:13:30)
at Module._compile (module.js:460:26)
/Users/ccasad/.npm-packages/lib/node_modules/ionic/node_modules/ionic-app-lib/lib/start_wizard.js:94
ps.stdout.on('data', (data) => {
^^
Unexpected token => (CLI v2.2.1)
Your system information:
Cordova CLI: 6.5.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
ios-deploy version: 1.8.2
ios-sim version: 5.0.3
OS: OS X Yosemite
Node Version: v0.12.6
Xcode version: Xcode 7.2.1 Build version 7C1002
I've had things running fine for ionic v1 so not sure why things in npm aren't working for v2. The error almost seems like it doesn't understand ES6 arrow functions or something since it's saying unexpected token on the =>.
Any ideas how to deal with this? Do I need to reinstall node?
Thanks
Best way uninstall and delete node from C:\Program Files or C:\Program Files (x86) and install the latest version.
OR
This is a ionic bug in this file
C:\Users\{user}\AppData\Roaming\npm\node_modules\ionic\node_modules\ionic-app-lib\lib\start_wizard.js
For compile this syntax of node.js you need to new version of Node.js and so you must be change all lambda syntax from function to normalize codes for older versions:
ps.stdout.on('data', (data) => {
var d = data.toString('utf-8');
if(d.indexOf('dev server running') >= 0) {
res.writeHead(200, {'Content-Type': 'application/json'});
res.end(JSON.stringify({
'status': 'success'
}));
}
process.stdout.write(d);
});
To :
ps.stdout.on('data',function (data) {
var d = data.toString('utf-8');
if(d.indexOf('dev server running') >= 0) {
res.writeHead(200, {'Content-Type': 'application/json'});
res.end(JSON.stringify({
'status': 'success'
}));
}
process.stdout.write(d);
});
Full Correct file : Download
I am not sure this way it could work for you, even i had a issue i have resolved this way . I believe look like node migration issue .Try to set latest version (e.g 6.9.4).Before doing do clean npm and then install.Hope this should work

Pipeline script to upload build(apk) to hockeyApp

I am using Jenkins to build my android app. i added "Jenkinsfile" in my repo and my current pipeline script looks like this and it is working fine.
node
{
try {
stage("build.clone")
{
checkout scm
}
stage("build.clean")
{
sh "./gradlew clean"
}
stage("build.package")
{
sh "./gradlew assembleDebug"
}
} catch (error) {
throw error
}
}
Now i need to upload my apk to hockeyapp. HockeyApp's Jenkins plugin is installed. And they have made it compatible with pipeline in v 1.2.2
I have googled a lot but found not much help. Kindly guide me or point me to how I can use pipeline script to upload apk to hockeyapp.
Note: I have already created an app on hockey app and I have app token and app id. Also i know curl command is available but i want to use hockeyapp plugin with pipeline
You should be able to get the syntax for just about any Pipeline step via the snippet generator built in to Jenkins.
Doing so in my Jenkins install gives me something like this (horrifying) syntax:
step([$class: 'HockeyappRecorder',
applications: [[downloadAllowed: false, mandatory: false,
notifyTeam: false, releaseNotesMethod: [$class: 'NoReleaseNotes'],
uploadMethod: [$class: 'AppCreation', publicPage: false]]],
debugMode: false, failGracefully: false])

Categories

Resources