In Jenkins Computer class, why is getDescription restricted? - jenkins

If you go to:
https://javadoc.jenkins-ci.org/hudson/model/Computer.html#getDescription--
It shows:
#Restricted(value=org.kohsuke.accmod.restrictions.DoNotUse.class)
#Exported
#NonNull
public String getDescription()
Returns the Node description for this computer. Empty String if the Node is null.
Which results in error during mvn install if you used this method. What's the reason for restricting this method?

Related

Spring Data Query into Elastic search for exact match

I am learning elasticsearch with spring data so can someone help me understand better what elasticsearch query is doing here. I am trying to return back only a set of results based off of a certain value, in this case env. It seems to me that this JPQL query, is not making a difference to only return what I ask for. I have also used an #Query with no difference.
-- here is part of my repository class
public interface MyFormRepo extends ElasticsearchRepository<MyForm, String> {
//??? these function calls are not effecting my return
#Query("{\"bool\": {\"must\": [{\"match\": {\"env\": \"?0\"}}]}}")
Page<MyForm> getAllByEnv(String env, Pageable pageable);
Page<MyForm> findAllByEnv(String env, Pageable pageable);
-- Here is part of my entity class
#Document(indexName = "my_form")
public class MyForm {
#Id
private String id;
#Field(type = Text)
private String schema;
#Field(type = Long)
private long version;
#Field(type = Text)
private String env;
Here is what I understand. Elasticsearch has this concept called Fuzziness (https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#fuzziness) so in it's searches which is based on Levenshtein distance (https://en.wikipedia.org/wiki/Levenshtein_distance). Spring data does not allow us to modify this out of the box and is considered Fuzziness.AUTO by default. https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#elasticsearch.misc. As for the queries neither of them will do anything different. Both findByAllEnv and getAllBeEnv has a fuziness.AUTO, as for the #Query I found a good reason stated at this site: What is difference between match and bool must match query in Elasticsearch. What I ended up finding is that I must implemented a custom repo for that I have found this example/explaination How to query Elastic with Spring-data-elastic.

Can't see origin from: "Non-nullable instance field ‘{0}’ must be initialized."

So I am trying to get into app development and following this guys yt-tutorial (yt-vid from The Net Ninja). However I stumbled over the following error:
Non-nullable instance field ‘{0}’ must be initialized. (error on dart.dev explained). The whole code is shown in this image
img coding: comparison mine with yt:
The issue I am facing is that I don't understand the origin of that error. I understand that you can't use a variable that was not initialized yet and that this error is trying to tell you that before you run the code and run into an exception in runtime.
I also know that I can fix this using "late" in front of the variables, but as far as I'm concerned that's just "ignoring" the error.
So my main question is: why do I have this error while the yt doesn't even though we have (except for some names and assignments) the same code?
I appreciate every answer and hope you have a great day
the links:
error on dart.dev explained
You should change your User class to:
class User {
String username;
int age;
User(this.username, this.age);
}
By doing so, the variables will be initialized with values (since we are then able to use this values in the constructor body) as part of initialization of the object.
Dart does object creation in two steps:
Initialize object.
Run constructor body.
So when the constructor body is running, the object must be initialized with values (well, the non-nullable values at least). To do so, we have a code block which is executed before { } like:
class User {
String username;
int age;
User(String username, int age)
: this.username = username,
this.age = age;
}
But since this is kinda redundant, we have the shortcut form as I first suggested.
When initializing an object, we are not allowed to use variables from the object since the object is ongoing its creation.

Use Jenkins-Plugin in Jenkins-Pipeline

I'm trying to incorporate the ClearCase UCM Plugin into a Jenkins-Pipeline. Currently, I'm using the step-method to invoke the ClearCase-plugin:
step([
$class: 'hudson.plugins.clearcase.ClearCaseUcmSCM',
stream: "MY_STREAM",
loadrules: "load \\SOMETHING\\int load \\OTHER load \\RESOURCES",
[...]
changeset: "BRANCH",
viewStorage: null
])
As far as I understood the plugin-system the instantiation is done using the constructor annotated with #DataBoundConstructor:
src/main/java/hudson/plugins/clearcase/ClearCaseUcmSCM.java:
#DataBoundConstructor
public ClearCaseUcmSCM(String stream, String loadrules, String viewTag, boolean usedynamicview, String viewdrive, String mkviewoptionalparam,
boolean filterOutDestroySubBranchEvent, boolean useUpdate, boolean rmviewonrename, String excludedRegions, String multiSitePollBuffer,
String overrideBranchName, boolean createDynView, boolean freezeCode, boolean recreateView, boolean allocateViewName, String viewPath,
boolean useManualLoadRules, ChangeSetLevel changeset, ViewStorage viewStorage, boolean buildFoundationBaseline) {
I copied most of the parameters (boolean, String, integers) from a similar project's config.xml-file. Unfortunately, I get an Exception:
"java.lang.IllegalArgumentException: argument type mismatch"
I guess it's because I can't create "ChangeSetLevel" and "ViewStorage" (the latter is not even in the config.xml).
So my question is how to invoke the plugin properly.
Additionally, I'd like to know how to pass "loadrules" properly as there seems to be newlines in the config.xml:
"load \\SOMETHING\\int[NEWLINE] load \\OTHER[NEWLINE] load \\RESOURCES"
You can take a look at Pipeline Syntax of your job and use Snippet Generator to construct your step. It can be found at http://[jenkins-url]/pipeline-syntax.
More info in the Jenkins pipeline docs.

AssertionError instead of failure

i have developed a test package using SWTbot and ant to build it , when i run it, it finds that there is a failure however in the test report it shows as an error instead of failure:
my code is :
public static void Check_TargetPack(final SWTWorkbenchBot bot,String configuration,
String targetpack) {
boolean exist=false;
String[] h=bot.comboBoxWithLabel("TargetPack").items();
int i=0;
for (i=0;i<h.length;i++){
if (h[i]==targetpack)exist=true;
assertTrue("target pack"+targetpack+" doesn't exist in targetpack list",exist);
};
bot.sleep(2000);
bot.button("Close").click();
}
and the result is
I can see one problem in your code.
You are matching Strings with "==" operator.
You should use following instead
h[i].equals(targetpack)

Neo4j server plugin - function return value

I am developing server plugin.
On documentation I read this :
ensure that it can produce an (Iterable of) Node, Relationship or Path, any Java primitive or String or an instance of a org.neo4j.server.rest.repr.Representation
What does it mean?
is it like always I have to return public Iterable<SOMETHING_HERE> function(){} Or I can return anything like like public int function {}
Thanks
Amit Aggarwal
The valid return types of server plugins are:
* Node, Relationship, Path, java primitve, String or org.neo4j.server.rest.repr.Representation
* or an iterable of the above
Since int is a java primitive, your plugin method can safely return a int. See https://github.com/jimwebber/neo4j-tutorial/blob/master/src/koan/java/org/neo4j/tutorial/koan13/AwesomenessServerPlugin.java for an example.

Resources