Publish on HockeyApp application with declarative pipeline - How integrate Android tools

173 views
Skip to first unread message

Francesco Sisca

unread,
Apr 6, 2018, 9:46:38 AM4/6/18
to Jenkins Users
Hello everyone, i have a trouble.

i need, after build, to publish my application on Hockeyapp. I'm trying to do this, but get an error. this is my pipeline

pipeline {
    agent any
        tools {
        gradle "gradle"
    }

    stages {
        stage('Check Env Works'){
            steps {
                nodejs(nodeJSInstallationName: 'nodejs') {
                    sh 'env'
                    sh 'npm -v'
                    sh 'gulp -v'
                    sh 'cordova -v'
                    sh 'java -version'
                    sh 'node -v'
                    sh 'tslint -v'
                    sh 'ionic info'
                    sh 'gradle -v'

                }
            }
        }
        stage('Download dependency from Nexus'){
            steps {
                nodejs(nodeJSInstallationName: 'nodejs') {
                    sh 'npm config get registry'
                    sh 'npm whoami'
                    sh 'npm i'
                }
            }
        }
        stage('Build APK file'){
            steps {
                nodejs(nodeJSInstallationName: 'nodejs') {
                    sh 'ionic cordova build android'
                }
            }
        }
        stage('Upload APK to HockeyApp'){
            steps {
                sh 'curl \
                  -F "status=2" \
                  -F "notify=1" \
                  -F "notes=Some new features and fixed bugs." \
                  -F "notes_type=0" \
                  -F "apk=@hockeyapp.apk" \
                  -H "X-HockeyAppToken: XXXXXX" \
            }
        }
    }

    post {
         always { 
             mail bcc: '', body: "<b>Example</b><br>\n<br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> URL de build: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "Always CI: Project name -> ${env.JOB_NAME}", to: "x";  
         }  
         success {  
             mail bcc: '', body: "<b>Example</b><br>\n<br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> URL de build: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "Success CI: Project name -> ${env.JOB_NAME}", to: "x";  
         }  
         failure {  
             mail bcc: '', body: "<b>Example</b><br>\n<br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> URL de build: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "Failur CI: Project name -> ${env.JOB_NAME}", to: "x";  
         }  
         unstable {  
             mail bcc: '', body: "<b>Example</b><br>\n<br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> URL de build: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "Unstable CI: Project name -> ${env.JOB_NAME}", to: "x";  
         }  
         changed { 
             mail bcc: '', body: "<b>Example</b><br>\n<br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> URL de build: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "Changed CI: Project name -> ${env.JOB_NAME}", to: "x";  
         }  
    }
}

but when i ran this, i get this error

(node:1183) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: /opt/jenkins/work/workspace/PipelineMobileHubReferenceApplication/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* Where:
Script '/opt/jenkins/work/workspace/PipelineMobileHubReferenceApplication/platforms/android/CordovaLib/cordova.gradle' line: 68

* What went wrong:
A problem occurred evaluating project ':CordovaLib'.
> No installed build tools found. Install the Android build tools version 19.1.0 or higher.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s




how i solve this? Here the complete log

Started by user admin
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on Jenkins in /opt/jenkins/work/workspace/PipelineMobileHubReferenceApplication
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://lllllllllllll/mobilehub-reference-application.git # timeout=10
 > git --version # timeout=10
using GIT_ASKPASS to set credentials 
 > git fetch --tags --progress https://lllllllllll/lllll/mobilehub-reference-application.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 62411791381e4dc2cf53348ac8bcf3abc9abc8c2 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 62411791381e4dc2cf53348ac8bcf3abc9abc8c2
Commit message: "Merge branch 'master' of https://llllllllllll/mobilehub-reference-application"
 > git rev-list --no-walk 62411791381e4dc2cf53348ac8bcf3abc9abc8c2 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Tool Install)
[Pipeline] tool
[Pipeline] envVarsForTool
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Check Env Works)
[Pipeline] tool
[Pipeline] envVarsForTool
[Pipeline] withEnv
[Pipeline] {
[Pipeline] nodejs
[Pipeline] {
[Pipeline] sh
[PipelineMobileHubReferenceApplication] Running shell script
+ env
JENKINS_NODE_COOKIE=fb6529c7-bdb7-4b35-8cf1-12bf45674b2d
ANDROID_HOME=/home/jenkins/android-sdk-linux/
SHELL=/bin/bash
HUDSON_SERVER_COOKIE=d26097bd0587020a
STAGE_NAME=Check Env Works
BUILD_TAG=jenkins-PipelineMobileHubReferenceApplication-67
GIT_PREVIOUS_COMMIT=62411791381e4dc2cf53348ac8bcf3abc9abc8c2
WORKSPACE=/opt/jenkins/work/workspace/PipelineMobileHubReferenceApplication
USER=jenkins
GIT_COMMIT=62411791381e4dc2cf53348ac8bcf3abc9abc8c2
JENKINS_HOME=/opt/jenkins/work
NLSPATH=/usr/dt/lib/nls/msg/%L/%N.cat
PATH=/opt/jenkins/work/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/nodejs/bin:/opt/jenkins/tools/gradle-4.0.1/bin:/opt/jenkins/tools/gradle-4.0.1/bin:/sbin:/usr/sbin:/bin:/usr/bin
_=/bin/env
PWD=/opt/jenkins/work/workspace/PipelineMobileHubReferenceApplication
JAVA_HOME=/opt/jenkins/tools/jdk1.8.0_131
LANG=en_US.UTF-8
JOB_NAME=PipelineMobileHubReferenceApplication
XFILESEARCHPATH=/usr/dt/app-defaults/%L/Dt
BUILD_DISPLAY_NAME=#67
BUILD_ID=67
GIT_PREVIOUS_SUCCESSFUL_COMMIT=79195607157f75492619dea020fec98615a31e1e
JOB_BASE_NAME=PipelineMobileHubReferenceApplication
HOME=/home/jenkins
SHLVL=4
GIT_BRANCH=origin/master
NODEJS_HOME=/opt/jenkins/work/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/nodejs
EXECUTOR_NUMBER=1
JENKINS_SERVER_COOKIE=durable-d2c3c254b85331971a64568663ab83e9
NODE_LABELS=master
LOGNAME=jenkins
CHROME_BIN=C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
HUDSON_HOME=/opt/jenkins/work
GEM_PATH=file:/opt/jenkins/work/plugins/ruby-runtime/WEB-INF/lib/stapler-jruby-1.209.jar!/gem
NODE_NAME=master
BUILD_NUMBER=67
HUDSON_COOKIE=
[Pipeline] sh
[PipelineMobileHubReferenceApplication] Running shell script
+ npm -v
3.10.9
[Pipeline] sh
[PipelineMobileHubReferenceApplication] Running shell script
+ gulp -v
[13:35:37] CLI version 2.0.1
[13:35:37] Local version 3.9.1
[Pipeline] sh
[PipelineMobileHubReferenceApplication] Running shell script
+ cordova -v

You have been opted out of telemetry. To change this, run: cordova telemetry on.
8.0.0
[Pipeline] sh
[PipelineMobileHubReferenceApplication] Running shell script
+ java -version
openjdk version "1.8.0_141"
OpenJDK Runtime Environment (build 1.8.0_141-b16)
OpenJDK 64-Bit Server VM (build 25.141-b16, mixed mode)
[Pipeline] sh
[PipelineMobileHubReferenceApplication] Running shell script
+ node -v
v6.9.2
[Pipeline] sh
[PipelineMobileHubReferenceApplication] Running shell script
+ tslint -v
5.9.1
[Pipeline] sh
[PipelineMobileHubReferenceApplication] Running shell script
+ ionic info

cli packages: (/opt/jenkins/work/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/nodejs/lib/node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0 

local packages:

    @ionic/app-scripts : 1.3.7
    Cordova Platforms  : android 7.0.0
    Ionic Framework    : ionic-angular 3.5.0

System:

    Android SDK Tools : 26.1.1
    Node              : v6.9.2
    npm               : 3.10.9 
    OS                : Linux 3.10

Environment Variables:

    ANDROID_HOME : /home/jenkins/android-sdk-linux/

Misc:

    backend : pro

[Pipeline] sh
[PipelineMobileHubReferenceApplication] Running shell script
+ gradle -v

------------------------------------------------------------
Gradle 4.0.1
------------------------------------------------------------

Build time:   2017-07-07 14:02:41 UTC
Revision:     38e5dc0f772daecca1d2681885d3d85414eb6826

Groovy:       2.4.11
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          1.8.0_131 (Oracle Corporation 25.131-b11)
OS:           Linux 3.10.0-514.26.2.el7.x86_64 amd64

[Pipeline] }
[Pipeline] // nodejs
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Download dependency from Nexus)
[Pipeline] tool
[Pipeline] envVarsForTool
[Pipeline] withEnv
[Pipeline] {
[Pipeline] nodejs
[Pipeline] {
[Pipeline] sh
[PipelineMobileHubReferenceApplication] Running shell script
+ npm config get registry
[Pipeline] sh
[PipelineMobileHubReferenceApplication] Running shell script
+ npm whoami
mobilehub-developer
[Pipeline] sh
[PipelineMobileHubReferenceApplication] Running shell script
+ npm i

> application_skeleton@ postinstall /opt/jenkins/work/workspace/PipelineMobileHubReferenceApplication
> gulp ui:core

[13:36:05] Using gulpfile /opt/jenkins/work/workspace/PipelineMobileHubReferenceApplication/gulpfile.js
[13:36:05] Starting 'ui:del'...
Deleted dest directory before ui:move!
[13:36:05] Starting 'ui:moveimg'...
Moving images!
[13:36:05] Finished 'ui:del' after 95 ms
[13:36:05] Starting 'ui:move'...
Moving components!
[13:36:05] Finished 'ui:moveimg' after 336 ms
[13:36:05] Finished 'ui:move' after 316 ms
[13:36:05] Starting 'ui:delete'...
[13:36:06] Finished 'ui:delete' after 9.92 ms
[13:36:06] Starting 'ui:core'...
[13:36:06] Finished 'ui:core' after 6.1 μs
Deleted Mobilehub-ui-core from node_modules!
application_skeleton@ /opt/jenkins/work/workspace/PipelineMobileHubReferenceApplication
├── UNMET PEER DEPENDENCY @ionic-native/co...@4.5.3
├── mobilehu...@1.0.27 
└── UNMET PEER DEPENDENCY zon...@0.8.11

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsev...@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/webpack-dev-server/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsev...@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/@ionic/app-scripts/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsev...@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN @ionic-native/splash...@3.14.0 requires a peer of @ionic-native/core@^3.6.0 but none was installed.
npm WARN @ionic-native/statu...@3.12.1 requires a peer of @ionic-native/core@^3.6.0 but none was installed.
npm WARN ionic-...@3.5.0 requires a peer of zon...@0.8.12 but none was installed.
[Pipeline] }
[Pipeline] // nodejs
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build APK file)
[Pipeline] tool
[Pipeline] envVarsForTool
[Pipeline] withEnv
[Pipeline] {
[Pipeline] nodejs
[Pipeline] {
[Pipeline] sh
[PipelineMobileHubReferenceApplication] Running shell script
+ ionic cordova build android
Running app-scripts build: --platform android --target cordova
[13:36:26]  build dev started ... 
[13:36:26]  clean started ... 
[13:36:26]  clean finished in 5 ms 
[13:36:26]  copy started ... 
[13:36:26]  transpile started ... 
[13:36:31]  transpile finished in 5.42 s 
[13:36:31]  preprocess started ... 
[13:36:31]  deeplinks started ... 
[13:36:32]  deeplinks finished in 277 ms 
[13:36:32]  preprocess finished in 278 ms 
[13:36:32]  webpack started ... 
[13:36:35]  copy finished in 8.64 s 
[13:36:46]  webpack finished in 14.03 s 
[13:36:46]  sass started ... 
[13:36:53]  sass finished in 7.02 s 
[13:36:53]  postprocess started ... 
[13:36:53]  removed unused font files 
[13:36:53]  postprocess finished in 14 ms 
[13:36:53]  lint started ... 
[13:36:53]  build dev finished in 26.88 s 
> cordova build android

You have been opted out of telemetry. To change this, run: cordova telemetry on.
Android Studio project detected
ANDROID_HOME=/home/jenkins/android-sdk-linux/
JAVA_HOME=/opt/jenkins/tools/jdk1.8.0_131
studio
Subproject Path: CordovaLib
Subproject Path: app
[13:36:55]  lint finished in 2.81 s 
Starting a Gradle Daemon (subsequent builds will be faster)

FAILURE: Build failed with an exception.

* Where:
Script '/opt/jenkins/work/workspace/PipelineMobileHubReferenceApplication/platforms/android/CordovaLib/cordova.gradle' line: 68

* What went wrong:
A problem occurred evaluating project ':CordovaLib'.
> No installed build tools found. Install the Android build tools version 19.1.0 or higher.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
(node:1183) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: /opt/jenkins/work/workspace/PipelineMobileHubReferenceApplication/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* Where:
Script '/opt/jenkins/work/workspace/PipelineMobileHubReferenceApplication/platforms/android/CordovaLib/cordova.gradle' line: 68

* What went wrong:
A problem occurred evaluating project ':CordovaLib'.
> No installed build tools found. Install the Android build tools version 19.1.0 or higher.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s

[Pipeline] }
[Pipeline] // nodejs
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Upload APK to HockeyApp)
[Pipeline] tool
[Pipeline] envVarsForTool
[Pipeline] withEnv
[Pipeline] {
[Pipeline] sh
[PipelineMobileHubReferenceApplication] Running shell script
+ curl -F status=2 -F notify=1 -F 'notes=Some new features and fixed bugs.' -F notes_type=0 -F apk=@hockeyapp.apk -H 'X-HockeyAppToken: jjjjj' https://rink.hockeyapp.net/api/2/apps/jjjjjj/0.0.0.0.5/upload
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (26) couldn't open file "hockeyapp.apk"
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] mail
[Pipeline] mail
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 26
Finished: FAILURE



Reply all
Reply to author
Forward
0 new messages