TeamCity, Android, Gradle Script failure - android

I have been struggling to get TeamCity to build my Android Project. I have finally gotten the server to be able to compile the project with Gradlew (although I have to ignore lint errors, which I am not happy about - it will not tell me which lint errors are being violated EDIT: I found it in ..\build\outputs\lint-results.html)
But now I can see that it is trying to execute the following:
C:\TeamCity\buildAgent\work\284714bad9f1a533\MyProject>gradlew.bat --init-script C:\TeamCity\buildAgent\plugins\gradle-runner\scripts\init.gradle clean build
And I am getting the following error:
FAILURE: Build failed with an exception.
* Where:
Initialization script 'C:\TeamCity\buildAgent\plugins\gradlerunner\scripts\init.gradle' line: 31
* What went wrong:
A problem occurred evaluating initialization script.
> Cannot invoke method split() on null object
I have checked this line and it seems fairly standard:
initscript {
dependencies {
def teamCityInitLib = System.getenv("TEAMCITY_BUILD_INIT_PATH")
println "Init lib: ${teamCityInitLib}"
def classPathFiles = teamCityInitLib.split(File.pathSeparator) //line 31
classpath files(classPathFiles)
}
}
Can anyone help me? NOTE: the following command works without a problem:
gradlew.bat clean build

Seems that you don't have TEAMCITY_BUILD_INIT_PATH variable in your PATH on your build machine. You can add it either by standart ways, depending on OS, or by adding it to Build Parameters in Configuration Steps of your build.

It seems like the build file is not being found. At least, that is what support is telling me. To me this is a TeamCity bug and not on my side. When I find out more, I'll post it.

Found this post while looking for a way to emulate a TC build from the command line and trying to understand how to set TEAMCITY_BUILD_INIT_PATH.
In my environment I determined that it's set to:
/apps/teamcity-agent/agent/lib/serviceMessages.jar:/apps/teamcity-agent/agent/lib/runtime-util.jar:/apps/teamcity-agent/agent/plugins/gradle-runner/lib/gradle-runner-common.jar
Where /apps/teamcity-agent is the my TC install path.
Hope this helps.

Related

Unable to make a pull in gradle file

i´m trying to make a task in Gradle for my Android project ( using Kotlin DSL ) where I need to do an automatic pull for my "develop" branch.
This are the commnand I want to run :
git pull origin develop:develop
In the terminal this works just fine.
I`m using "commandLine" with "exec" in my gradle file and I´m having this error message:
code:
tasks.register<ReleaseTask>("makePull") {
exec { commandLine("git", "pull", "origin develop:develop") }
}
error message:
ssh: Could not resolve hostname origin develop: nodename nor servname provided, or not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
FAILURE: Build failed with an exception.
I don´t have any issue if I try this commands in the terminal, do you know what i´m doing wrong ?
You haven't separated the origin and the develop:develop arguments in the gradle version. Use this instead:
commandLine("git", "pull", "origin", "develop:develop")

Android Detekt Build failed

I tried to generate code report using detekt and when execute the below command in terminal
gradle detekt
it showing build failed with below message.
* What went wrong:
Execution failed for task ':app:detekt'.
> Build failed with 395 weighted issues.
As others have said in the comments, this means you have 395 issues in your code (kind of like lint warnings).
Detekt has a maxissues: property that determines whether or not to fail the build if your issues surpass the allowed number of maxissues. What I did was search the whole project for maxissues, which will take you to your detekt-config.yml or default-detekt-config.yml. There, you can change your maxissues to whatever you want.
In our old code base, we had 900 some issues, so I changed mine from maxissues:0 to masissues:1000. As we clean up the code, I hope to bring that number down.

New Relic - java.io.IOException: File exists

I experience problems when trying to build my Android project which depends on New Relic. See grade command and stack trace below.
Command:
./gradlew clean assembleProdDebug assembleProdDebugTest
See terminal output below:
...
:my-project:my-project:packageReleaseJniLibs[newrelic] Error encountered while loading the New Relic agent
java.io.IOException: File exists
at sun.tools.attach.BsdVirtualMachine.createAttachFile(Native Method)
at sun.tools.attach.BsdVirtualMachine.<init>(BsdVirtualMachine.java:74)
at sun.tools.attach.BsdAttachProvider.attachVirtualMachine(BsdAttachProvider.java:63)
at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:208)
at com.sun.tools.attach.VirtualMachine$attach.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.newrelic.agent.android.NewRelicTask.injectAgent(NewRelicTask.groovy:45)
at com.newrelic.agent.android.NewRelicTask$injectAgent$0.callCurrent(Unknown Source)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':my-project:newRelicInstrumentTask'.
> java.io.IOException: File exists
It complains about "File exists" but it doesn't say anything about what file or where or how to solve it.
Top level build.gradle file has the following dependency:
classpath "com.newrelic.agent.android:agent-gradle-plugin:4.+"
and each of the two apps has the following:
compile 'com.newrelic.agent.android:android-agent:4.273.4'
New Relic and the build process worked perfectly fine until I merged two apps into the same Android studio project. I did this because the two apps share a lot of code with each other.
Anyone experienced the same problem? Any ideas on how to solve it? Just ask if you need more information.

Error deploying artifact: Failed to transfer file Return code is: 401

I am trying to upload my library, ListBuddies, to maven. To do that I am using the gradle-mvn-push github project of #ChrisBanes . I follow all the steps that he mentioned on his repo plus some others that are needed before that repo is used:
I opened a Jira issue and I waited until It got resolved
I have created GPG keys
I configurate ListBuddies's build.gradle files and the gradle.properties
I have created another local gradle.properties at "/Users/jpardogo/.gradle/gradle.properties"
local gradle.properties file (signing keys are only need for release so should not be a problem for the SNAPSHOT):
//These are the username/password that I use for:
//[JIRA](https://issues.sonatype.org)
//and [NEXUS](https://oss.sonatype.org
NEXUS_USERNAME=jpardogo1
NEXUS_PASSWORD=jira-pass
//This is the key ID that I obtain doing "gpg --list-keys" on the terminal
signing.keyId=my-keyid
//This is the paraphrase I set when I first created the key
signing.password=my-paraphrase
//That's the path to my secret key ring
signing.secretKeyRingFile=/Users/jpardogo/.gnupg/secring.gpg
Look like everything is setup properly but when I do:
gradle clean build uploadArchives
At the end I receive code ERROR 401:
:library:uploadArchives
Uploading: com/jpardogo/listbuddies/library/1.0.0-SNAPSHOT/library-1.0.0-20140209.151716- 1.aar to repository remote at https://oss.sonatype.org/content/repositories/snapshots/
Transferring 67K from remote
:library:uploadArchives FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':library:uploadArchives'.
> Could not publish configuration 'archives'
> Error deploying artifact 'com.jpardogo.listbuddies:library:aar': Error deploying artifact: Failed to transfer file: https://oss.sonatype.org/content/repositories/snapshots/com/jpardogo/listbuddies/library/1.0.0-SNAPSHOT/library-1.0.0-20140209.151716-1.aar. Return code is: 401
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
I have been looking for an answer the whole day of yesterday and today as well but I couldn't solve it. The error 401 reason is good explain in here, but I couldn't solved anything and I also read that It could be due user permissions problem although I register on Jira as the guide says.
I hope you can help me with that and If you need any more information, please let me know. Thanks.
EDIT: I want to update the question with the link to the jira ticket and its comments.
I finally solved it. All the configuration was ok. The problem was on the file gradle.properties. Because I copy paste the structure of the file, a hidden tabulation reminded next to the NEXUS_USERNAME, so the username actually was being sent with the tabulation and I was receiving a authentication error.
Sometimes things are more simple than you think, and you don't see them. The first thing I will do the next time will be to check the format of the files.
I had exactly the same problem, and the reason was: my password (generated) contained a backslash \.
Solution: Backslashes need to be escaped in gradle.properties!
Example:
ossrhPassword=partBeforeBackslash\\\\partAfterBackslash
instead of:
ossrhPassword=partBeforeBackslash\partAfterBackslash
For me the problem was that I was uploading a version that already exists in the rep. The solution was just to change the 'version' in the build.gradle file.

Gradle in Android Studio 0.44 can't find process on path to run in an Exec Type task

I used to have the following gradle build task:
task buildWebApp(type: Exec) {
executable = Os.isFamily(Os.FAMILY_WINDOWS) ? "grunt.cmd" : "grunt"
args = ["build"]
}
This would pick the appropriate grunt command and run it with the argument "build".
This worked without any kind of issue
I've just tried this in Android Studio 0.4, using Gradle 1.9 and it's no longer working. Instead I get the following error:
Execution failed for task ':BrowserPages:buildWebApp'.
A problem occurred starting process 'command 'grunt''
Normally at this point I would debug with gradlew, but running the following command, throws no errors:
$ ./gradlew buildWebApp
I've also tried running the full task list to still not find any problems.
The way this is executed is from my main build.gradle file with this dependency
copyWebApplication.dependsOn ':BrowserPages:buildWebApp'
Anyone have any ideas?
I've tried to run executable = "node" with arg = ["-v"] and get the same error where it can't find node. Node is globally accessible on my terminal, so I can only assume that the command is being run in a different environment to the terminal. There is the option for setting the environment but I can't find any examples of how it should be used.
Try using a fully-qualified path to the grunt executable. Perhaps something in the path has changed between Android Studio/Gradle/Android Plugin versions.

Categories

Resources