I am trying to use the below lines to get API response, but its not working for me.
Please help me.
Groovy ver = 2.4.15
OS = windows 7
#Grab(group='org.codehaus.groovy.modules.http-builder',module='http-builder',version='0.7.1')
import groovyx.net.http.HTTPBuilder
As mentioned in the comments, I think the best place to start would be to run your script with the following flag turned on:
~> groovy -Dgroovy.grape.report.downloads=true <yourscript>
that should give you some logging indicating what the grape resolution is doing and hopefully where it tried to download the file from when it failed.
For an overview of the grape resolution mechanics, you can refer to the groovy documentation on grapes.
My guess is that groovy is trying multiple resolvers (i.e. maven central, jcenter, etc) and one of them is failing early even though a later one has the artifact. In a situation like this the resolution engine naturally should keep trying until it finds a working artifact but I have seen things fail this way before.
To modify the resolution order and behavior, you should look at the file:
<your user home dir>/.groovy/grapeConfig.xml
where, if the file does not exist, groovy uses the following default data for the file:
<ivysettings>
<settings defaultResolver="downloadGrapes"/>
<resolvers>
<chain name="downloadGrapes" returnFirst="true">
<filesystem name="cachedGrapes">
<ivy pattern="${user.home}/.groovy/grapes/[organisation]/[module]/ivy-[revision].xml"/>
<artifact pattern="${user.home}/.groovy/grapes/[organisation]/[module]/[type]s/[artifact]-[revision](-[classifier]).[ext]"/>
</filesystem>
<ibiblio name="localm2" root="file:${user.home}/.m2/repository/" checkmodified="true" changingPattern=".*" changingMatcher="regexp" m2compatible="true"/>
<!-- todo add 'endorsed groovy extensions' resolver here -->
<ibiblio name="jcenter" root="https://jcenter.bintray.com/" m2compatible="true"/>
<ibiblio name="ibiblio" m2compatible="true"/>
</chain>
</resolvers>
</ivysettings>
(from the groovy github repo)
Two things to note here:
The returnFirst attribute. The resolution engine will try the resolvers one by one and return the first hit for this specific artifact. If my hunch is correct, this is not working correctly and an early resolver is failing and not giving a later resolver a chance to resolve the artifact.
The list of resolvers is ordered so changing this order will affect the result.
So, long story short: turn on debugging and see if that gives anything.
Then either modify or create the grapeConfig.xml file and either:
change the order of the ibiblio elements to change the resolution order
add another maven resolver (i.e. add another ibiblio node) for a target you have verified has the artifact (and add it first in the chain to make sure one of the others does not fail first).
or play with the returnFirst flag to see if setting it to false resolves your issue
Related
Yesterday I was able to run a plain Java class in Android Studio without any problems. I did this by creating an Application configuration:
... for running the main() method of some class I defined in the default app module, e.g.:
package com.example.myappname;
public class Api {
public static void main(String[] arguments) {
System.out.println("API test");
}
}
If I then pressed run:
... the output (which I can't show you now, because it doesn't work anymore) of main() would appear nicely in the Run Tool Window:
As far as I was aware, no gradle task or build process was invoked by running this type of configuration. But now, all of a sudden, it appears as though gradle is being executed before running, because it complains that task [:app:Api.main()] failed with message:
A problem occurred configuring project ':app'.
> Could not create task ':app:Api.main()'.
> SourceSet with name 'main' not found.
... as seen here:
I tried recreating the configuration and for the first run it worked as before again, but on rerunning the same gradle build error appears again.
Do you have any idea why this is happening and how I can solve this? Am I correct in thinking gradle should be omitted with these kinds of Application configurations?
When it worked, the output in the Run Tool Window would appear almost instantaneously and no elaborate build process appeared in the Build Tool Window, leading me to believe no gradle build process was being executed.
I got it to work again:
... but don't ask me how exactly. It appears to be very buggy.
After deleting all sorts of cache directories and files and searching all kinds of directories for the location of the configuration files I was able to find that the configurations are stored in .idea/workspace.xml of the project.
And one thing I appeared to notice is that the following "hidden" option is needed as a minimum (which I believe was not there, when it didn't work):
<method v="2">
<option name="Make" enabled="true" />
</method>
Here's a full example configuration:
<configuration name="API" type="Application" factoryName="Application" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="com.example.myappname.Api" />
<module name="MyAppName.app.main" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
But sometimes it works and sometimes it doesn't. It appears to be the most reliable if I signify the classpath (-cp option in the Android Studio dialog) to be MyAppName.app instead of MyAppName.app.main.
Ironically, it started to work again when the configuration dialog claimed it couldn't find the class I wanted to run and a red X appeared in the top right corner of the configuration icon:
So, it's all a bit of a mystery to me, as to why it sometimes works and other times it does not.
PS: I was wrong about gradle not building in this type of configuration; it does.
And after a few more tests, it appears one simply shouldn't select the ".main" part when choosing a module for the classpath argument, as that appears to be some specific gradle configuration/task I don't understand well enough.
In spite of Android Studio claiming it can't find the class then (and the red X appearing), it works.
I have two build projects. lets call them project A and project A.pack. When I force build project A it asks me for Boolean parameter if I want to build project A.pack.
But I can't make in publishers block of project A a correct way to force build the project A.pack. I use conditional task but it doesn't work. In log file ccnet writes only that it fails on conditional task. What a usual way to do this in ccnet?
Update:
Sorry for my English. It's not my first language.
What I wanted to do is this:
In project A I added Boolean parameter:
<booleanParameter>
<name>ExampleParam</name>
<true name="Yes">1</true>
<false name="No">0</false>
<display>Example Param</display>
<default>No</default>
<required>false</required>
</booleanParameter>
And added conditional forcebuild in publishers like this:
<publishers>
<!-- some other tasks .. -->
<conditional>
<conditions>
<compareCondition>
<value1>${ExampleParam}</value1>
<value2>1</value2>
<evaluation>equal</evaluation>
</compareCondition>
</conditions>
<tasks>
<forcebuild>
<project>A.pack</project>
<serverUri>tcp://localhost:21235/CruiseManager.rem</serverUri>
</forcebuild>
</tasks>
</conditional>
</publishers>
When I press "force" it asks me for "Example Param", I check "Yes" and when it finishes building dashboard says that build was succesful but ForceBuildPublisher task failed.
There is no information in server log about why force build task failed.
It's CruiseControl.NET-1.6.7
Update 20150808:
I convinced my colleagues to update CCnet. In version 1.8.5 it's possible to do a conditional build like I wrote.
If the boolean parameter is true then write to a file that A.pack watches. A.pack builds if the file gets dirty. See Filesystem Source Control Block for use by A.pack in listening to the file made dirty by A.
I'm using cruisecontrol.net for integration builds along with external source control. The source control (GETMODS) script fails, this is fine and I know why, but the build stays green for some reason when it's expected to fail. CruiseControl shows the exception on the output window below, so why doesn't the build fail?
ThoughtWorks.CruiseControl.Core.CruiseControlException: Source control operation failed:
at ThoughtWorks.CruiseControl.Core.Sourcecontrol.ProcessSourceControl.Execute
(ProcessInfo processInfo)
at ThoughtWorks.CruiseControl.Core.Sourcecontrol.ProcessSourceControl.GetModifications(ProcessInfo info, DateTime from, DateTime to)
at ThoughtWorks.CruiseControl.Core.Sourcecontrol.ExternalSourceControl.GetMod ifications(IIntegrationResult from, IIntegrationResult to)
at ThoughtWorks.CruiseControl.Core.Sourcecontrol.QuietPeriod.GetModifications(ISourceControl sourceControl, IIntegrationResult lastBuild, IIntegrationResultthisBuild)
at ThoughtWorks.CruiseControl.Core.IntegrationRunner.GetModifications(IIntegrationResult from, IIntegrationResult to)
at ThoughtWorks.CruiseControl.Core.IntegrationRunner.Integrate(IntegrationRequest request)
at ThoughtWorks.CruiseControl.Core.Project.Integrate(IntegrationRequest request)
at ThoughtWorks.CruiseControl.Core.ProjectIntegrator.Integrate()
at ThoughtWorks.CruiseControl.Core.ProjectIntegrator.Run()
I guess the reasoning would be that the source control block is only used:
to check if there are any changes in the source code which require a rebuild, and
to get all the source code needed for the build.
If this action fails it has nothing to do with the source code and the commits to it. It's an infrastructural problem that prevents the build from happening at all therefore technically the build hasn't fails. It hasn't even started.
With a version control block inside cc.net, it search for repository modification.
If cc.net is unable to contact the repository, it can't start the job.
The result is an exception.
If you want to ignore this, this can help (simple retry counter) !
Can we tell CruiseControl.NET to ignore source control timeout errors?
<maxSourceControlRetries>5</maxSourceControlRetries>
<stopProjectOnReachingMaxSourceControlRetries>true</stopProjectOnReachingMaxSourceControlRetries>
<sourceControlErrorHandling>ReportOnRetryAmount</sourceControlErrorHandling>
I believe this is a recent change to ccnet. We are running two versions on separate machines. Version 1.4 breaks the build if it can't get to our svn repository, but version 1.5 will not break the build. I haven't looked into it yet, but there may be a switch to force 1.5 to break on failure to retrieve code.
I searched a lot but i didn't find a solution for my problem.
I use CruiseControl.NET (1.4.4). My project (in ccnet.config) load a repository from a cvs server to a local repository, and launch some executables (msbuild, NUnit...).
I use a trigger (Interval or Schedule Trigger), that launch regularly my project. But if my project has not been modified, it always launch all next tasks. And I would like to avoid it. So i want to launch my project only if a commit has been detected.
Is there any solution for it please?
Thanks
Olivier
Your trigger needs to specify IfModificationExists:
<intervalTrigger
name = "dave"
seconds = "30"
buildCondition = "IfModificationExists" />
Although buildCondition="IfModificationExists" is the default anyway, so as long as its not set to ForceBuild you should be fine.
EDIT:
The URL Trigger might be of some use to you. You can set your svn server to modify a page on commmit and the CC.Net checks the page to see if it has changed, thus not getting all the files.
I start my project as below, which ensures that the tasks get executed only if there are modifications.
Hope this helps,
Anders, Denmark
Edited: My code excerpt didn't make it to the page - I've tried to replace less-than, bigger-than with brackets.
[project name="SpilMerePool" queue="Q2" queuePriority="1"]
[sourcecontrol type="svn"]
[trunkUrl]https://ajf-ser1.ajf.local:8443/svn/SpilMerePool/trunk[/trunkUrl]
[workingDirectory]c:\from_vc\SpilMerePool[/workingDirectory]
[executable]C:\Program Files\VisualSVN Server\bin\svn.exe[/executable]
[username]username[/username]
[password]password[/password]
[/sourcecontrol]
Just use IntervalTrigger, like this:
<triggers>
<intervalTrigger />
</triggers>
You can also add an modificationDelaySeconds, to wait for a number of seconds before starting the build after the last commit.
<modificationDelaySeconds>30</modificationDelaySeconds>
Thank you Anders Juul abd Andy for your quick answers.
By using the intervalTrigger with "IfModificationExists" build condition, the project must be loaded each time (it's logical ^^). But my project size is about 450Mo. So it's a little long.
So my last question is : can we execute all builds and next tasks when a commit command has been detected? (without loading all files, in CruiseControl).
I use TortoiseCVS (version 1.10.10). Maybe we can force CruiseControl project to be lauched after a commit?
When I launch CruiseControl.NET with a particular configuration file I receive the following error:
ThoughtWorks.CruiseControl.Core.Config.ConfigurationException: Duplicate node detected
What does this mean, and what causes it?
I think you have 2 nodes in your config where it only expected one. Is there any chance you could post the config file it is throwing the exception on here as additional information? I'm using cruisecontrol (not the .net version) currently and find it can be very picky about it's XML files (rightly so) but not tell you anything about where in the file the exceptions were thrown from.
I found that I had an incorrectly structured config file. In particular, some blocks were outside of the configuration section. The error pointed to the second of these exec sections- apparently it didn't like that there was more than one of a given section inside the project.
Thus, the error occurred due a config file like this:
<project>
<tasks>
...
</tasks>
<exec>...</exec>
<exec>...</exec>
<project>
In my case I had something like:
<task>...</task>
<sourceControls>...</sourceControls>
<task>...</task>
<publishers>...</publishers>
It didn't like the two "<task>" nodes so I fixed it by removing the first "<task>" node. I was trying to do some stuff before getting the latest from svn, and then doing the build after that in the second "<task>" node. I'll need to revisit how to do that...any suggestions?