jenkins finished success while the make command failure - java

I used jenkins to build android image nightly, and then found even the make and cp command failure,the jenkins still finished success.
The last build setup is to copy log file to job directory, so maybe it succeed,and then jenkins finished SUCCESS.
And the Text-finder plugin can only set build unstable not failure, so how to make the build failure when make fails.
The log is like this:
make: \*** No rule to make target \`device/vendor/product/google_frameworks/Google_Play.apk', needed by `out/target/product/device/system/app/Google_Play.apk'. Stop.
make: *** Waiting for unfinished jobs....
target R.java/Manifest.java: FileBrowser(out/target/common/obj/APPS/FileBrowser_intermediates/src/R.stamp)
Warning: AndroidManifest.xml already defines versionCode (in http://schemas.android.com/apk/res/android); using existing value in manifest. untranslatable but exists in locale 'zh_CN'
aapt: warning: string 'pref_development_uastring' has no default translation in packages/apps/Browser/res; found: zh_CN zh_TW
Note: Recompile with -Xlint:unchecked for details.
======================>End<=======================
cp: cannot stat `/home/jenkins/job_name/source/out/target/product/device/package.img': No such file or directory
Extended Email Publisher is currently disabled in project settings
Finished: SUCCESS

The Jenkins job is marked as successfull if the last command of the script has succeed.
A simple workaround is to specify set -e at the begginning of your bash script.
-e Exit immediately if a command exits with a non-zero status.
You can also specify a trap: trap 'exit 1' ERR, to stop the script if an error occurs.

Related

./gradlew assemble fails due to missing file when the file clearly exists

I'm trying to build JPostal as described in this link using the following command:
./gradlew assemble
However, the command produces the following output claiming the file C:\x\Program Files\Msys64\usr\share does not exist when it clearly does:
$ ./gradlew assemble
:buildJniLibaclocal-1.16: error: aclocal: file '/x/Program Files/Msys64/usr/share/aclocal/tcl-tea.m4' does not exist
autoreconf-2.71: error: aclocal failed with exit status: 1
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type: Files/JPostal/src/main/jniLibs
configure: error: cannot find required auxiliary files: compile config.guess config.sub ltmain.sh missing install-sh
make: *** No rule to make target 'install'. Stop.
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':buildJniLib'.
> Process 'command 'sh'' finished with non-zero exit value 2
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 5.844 secs
I can clearly see a file named tcl-tea.m4 in the directory: C:\x\Program Files\Msys64\usr\share\aclocal
See the screenshot below:
If the file clearly exists, why am I getting this error? Why is the file being discriminated against?
Despite these are supported, but paths with spaces generally tend to be problematic on Linux.
Even without the build.gradle, the path is obviously wrong; this likely needs to be escaped:
"C:\\x\\Program\ Files\\Msys64\\usr\\share\\aclocal"
Where \\ gives \ and \ gives .
To use ${File.separator} would be the alternate cross-platform approach.
This would give \ on Windows and / on Linux.

Gradle task failing on GitLab CI main method not found

I'm in the process of setting up a new GitLab CI pipeline for a project.
As a start, my goal is to create a basic pipeline that builds, tests and analyzes the project (3 simple stages).
My problem is that, that my second stage (test) depends on a Gradle task that generates a bit of documentation (we generated on the fly documentation based on tests). Said task invokes the main of a utility to generate a simple piece of documentation.
While all tasks work fine when I run them under a Windows host, doing the same on GitLab's CI using an Alpine Linux based image fails with the following error:
> Task :compileTestJava
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
> Task :processTestResources NO-SOURCE
> Task :testClasses
> Task :test
> Task :generatePermissionsDocument FAILED
Error: Could not find or load main class
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':generatePermissionsDocument'.
> Process 'command '/opt/java/openjdk/bin/java'' finished with non-zero exit value 1
I have tried enabling Gradle stacktraces but I did not manage to get any good information out of them. For the most part both my build script and the GitLab CI script look OK (included below for reference):
image: adoptopenjdk/openjdk8:jdk8u222-b10-alpine
include:
- project: "devops/ci-templates"
ref: "master"
file: "sonar/sonar-gradle.yml"
variables:
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
- apk add --no-cache tzdata
- cp /usr/share/zoneinfo/America/New_York /etc/localtime
- echo "America/New_York" > /etc/timezone
stages:
- build
- test
- analysis
build:
stage: build
script: ./gradlew --build-cache clean assemble -PMARKETING_SKIP_INT_TESTS
cache:
key: "$CI_COMMIT_REF_NAME"
paths:
- build
- .gradle
- src/main/java/fts/marketing/util/Version.java
retry: 2
only:
- merge_requests
- master
- /^support\/\d+[.]\d+$/
- tags
except:
- api
test:
stage: test
script: ./gradlew test -PMARKETING_SKIP_INT_TESTS --stacktrace
cache:
key: "$CI_COMMIT_REF_NAME"
policy: pull
paths:
- build
- .gradle
- src/main/java/fts/marketing/util/Version.java
only:
- merge_requests
- master
- /^support\/\d+[.]\d+$/
- tags
except:
- api
Initially I though that the this would be a caching or permission related problem, but I checked both the integrity or the cache produced by the build task as well as the permissions of the generated folder and everything looks fine.
For reference the task I'm trying to invoke is this one:
task generatePermissionsDocument(type: JavaExec, group: 'application') {
description = 'Will generate API Permissions adoc'
main = 'fts.marketing.tools.GeneratePermissionsDocument'
classpath = sourceSets.main.runtimeClasspath
//jvmArgs = applicationDefaultJvmArgs
workingDir = generatedDocumentation
}
Can anyone shed some light as to why this is failing and what must be done to resolve it?
I managed to find out the root cases of this. I was doing some conditional setting of the application's default JVM args which apparently was wrong. Said process was including a trailing ',' in the args passed in by Gradle to the JVM.
For some reason this was not well liked when running from a Unix like environment, whereas it was working fine on Windows hosts. I re-worked the conditional part of the arg setting and everything worked like a charm.

GWT source build failure

I'm compiling a snapshot (current master) of gwt from source.
When running the command ant clean dist-dev, it results in the below build failure.
BUILD FAILED
C:\gwt_project\gwt\build.xml:53: The following error occurred while executing this line:
C:\gwt_project\gwt\distro-source\build.xml:23: Failed to copy C:\gwt_project\gwt\build\out\gwt-dev-merged.jar to C:\gwt_project\gwt\build\lib\gwt-dev.jar due to C:\gwt_project\gwt\build\lib\gwt-dev.jar
When running ant elemental dist-dev,it fails as below
BUILD FAILED
C:\gwt_project\gwt\build.xml:76: The following error occurred while executing this line:
C:\gwt_project\gwt\elemental\build.xml:20: Execute failed: java.io.IOException: Cannot run program "idl\build" (in directory "C:\gwt_project\gwt\elemental"): CreateProcess error=2, The system cannot find the file specified
I have tried executing these commands from an admin command prompt to check if it is a permission issue. However it still fails with the same result.
Probably Windows still holds the 'C:\gwt_project\gwt\build\out\gwt-dev-merged.jar' file, such that it can't be moved to the new location. Changing the ANT task from 'move' to 'copy' should fix the issue (in C:\gwt_project\gwt\distro-source\build.xml:23).

Can not run program, permission denied erro13 Jenkins

I created a new job for android new project on Jenkin. Whenever I run the job I got error java.io.ioexception error 13 permission denied. Jenkin says unable to run program gradlew. I know gradlew script need execution permissions according to the error explanation . I granted these and re run the jenkin job. I still get the same error. Jenkin revert the execution permission back after build. When I create new job from existing job and configured with old projects repository , it runs fine. when I configured with new project repository it raised permission issues. I played a lot with permission but no success. I also compared old and new project script file. There was few lines difference but it shouldn't be an issue. Any one can guide me what I am doing wrong.
Thanks
It is clearly a permission issue.
java.io.IOException: Cannot run program "<http://jenkins.gradlew"
error=13, Permission denied
Caused by: java.io.IOException: error=13, Permission denied
There are two solutions to resolve the gradlew permission issue.
Go to Jenkin Job configuration
Go to Build tab and check gradlew executable.
Jenkin will change the permission when you press build now. Keep in mind that these changes are uncommitted. The process works fine if your job is not a release job. If it is release job it creates another issue that I came across.
:workspace:app:checkCommitNeeded FAILED
:app:release FAILED
* What went wrong:
Execution failed for task ':workspace:app:checkCommitNeeded'.
> You have uncommitted files:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
M gradlew
So work around is
commit gradlew with executable bit set:
git update-index --chmod=+x gradlew
git commit
Then you will no longer need the jenkins setting to set it executable, which is the workaround causing the 2nd issue.
Hopefully it would save someone time because I spent hours for the work around.
I was using Github for source code management. It was fetching code there and was updating it every single time, so changing it to +x before submitting my Jenkins job didn't help.
In Linux the project is at /.jenkins/workspace/MyProjectName/SomeSubFolder/gradlew - and it was loosing +x evereytime a new job was submitted (to 644, I think).
The solution was to select the Make gradlew executable checkbox (in Build --> Use Gradle Wrapper) - it is 755 now, and is executing gradle tasks.
Are you using a jenkinsfile for your job configuration?
If so you need to add the permission change for gradlew there.
sh 'chmod 755 ./gradlew'
It sounds like your gradlew is being replaced each time with a version that doesn't have the execute permission set so you will need to do it as part of the jenkins job either via a script or the jenkinsfile.

Jenkins Cant Connect to Master

I have a setup up a master and slave on the same machine.
The master monitors External Jobs the slave runs a batch script and notifies the master about the same.
I followed the Windows instructions from:
https://wiki.jenkins-ci.org/display/JENKINS/Monitoring+external+jobs
and setup a buld step on the slave as follows:
set JENKINS_HOME=http://localhost:8080/jenkins/
java -jar C:\apache-tomcat-7.0.56\webapps\jenkins\WEB-INF\lib\jenkins-core-1.624.jar "POC_Main_Ext_Job" jenkins_poc_test_1
On building the slave job, I get the following error message in the console output:
Building remotely on MySlave in workspace D:\Temp\Jenkins\workspace\Slave_FreeStyle_1
[Slave_FreeStyle_1] $ cmd /c call C:\Users\ROHIT~1.BIS\AppData\Local\Temp\hudson853358493293228093.bat
D:\Temp\Jenkins\workspace\Slave_FreeStyle_1>set JENKINS_HOME=http://localhost:8080/jenkins/
D:\Temp\Jenkins\workspace\Slave_FreeStyle_1>java -jar C:\apache-tomcat-7.0.56\webapps\jenkins\WEB-INF\lib\jenkins-core-1.624.jar "POC_Main_Ext_Job" jenkins_poc_test_1
http://localhost:8080/jenkins/job/POC_Main_Ext_Job/ is not a valid external job (404 Not Found)
D:\Temp\Jenkins\workspace\Slave_FreeStyle_1>exit -1
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
However, the above url does work in Jenkins and takes to the corresponding job. Any Idea what I'm doing wrong?
As you can see I had missed out the user credentials while setting JENKINS_HOME.
After adding them it works smoothly.

Categories