SONARQUBE: how estract, via API, lines of code for each project - sonarqube

I've seen that I can found the line of code for a project on my SONAR instance using this command
http://<my_sonar_instance_url>/api/measures/component?componentKey=<project_name>&metricKeys=ncloc
and the output is
{
"component": {
"id": "<the_id>",
"key": "<the_key>",
"name": "<the_name>",
"qualifier": "TRK",
"measures": [
{
"metric": "ncloc",
"value": "37370"
}
]
}
}
That is fine!
Is there some way to extract the line of code of ALL my projects on SONAR "in bulk"? Or Do I've to cycle on my project list and extract them one to one?
Thank you in advance!

Related

Creating new project with template not renaming to sourceName

I've created a new Template for a .NET 6 project, and I'm trying to make sure it renames the project and solution file on creation. I have the following in my template.json file:
{
"$schema": "http://json.schemastore.org/template",
"author": "Jake Ford",
"classifications": [ "FordWareMVC", "FordWareMVC", "C#" ],
"identity": "FordWareTemplates.MVC",
"name": "FordWare MVC Template",
"shortName": "fordwaremvc",
"sourceName": "_fordwaremvc",
"tags": {
"language": "C#",
"type": "project"
}
}
and I am running the following command, using -n to set the source name and -o to set the folder directory for the new project:
dotnet new fordwaremvc -n NewProjectName -o NewProjectName
It creates the project, but the template/solution name is not "NewProjectName", it just uses the name of the original template project...
Am I doing something wrong with the sourceName?
Finally found the following:
sourceName: This is the value in your project/solution that will get replaced with the user-provided value in the -o parameter. Make sure this matches the name you chose when creating your template project / solution. The value above matches my project / solution name if you look at the template repo.
From here: https://knowyourtoolset.com/2021/08/creating-useful-net-templates/
The sourceName apparently needs to match the original solution/project name. I edited my template.json to this, and uninstalled/re-installed the template again and the original command worked:
{
"$schema": "http://json.schemastore.org/template",
"author": "Jake Ford",
"classifications": [ "FordWareMVC", "FordWareMVC", "C#" ],
"identity": "FordWareTemplates.MVC",
"name": "FordWare MVC Template",
"shortName": "fordwaremvc",
"sourceName": "FordWare_Template",
"tags": {
"language": "C#",
"type": "project"
}
}

Failed to run the pipeline (Pipeline) - Azure Data Factory

For testing purposes I'm trying to execute this simple pipeline (nothing sophisticated).
However, I'm getting this error:
{"code":"BadRequest","message":null,"target":"pipeline//runid/cb841f14-6fdd-43aa-a9c1-4619dab28cdd","details":null,"error":null}
The goal is to see if two variables are getting the right values (we have been facing some issues in our production environment).
This is the json with the definition of the pipeline:
{
"name": "GeneralTest",
"properties": {
"activities": [
{
"name": "Set variable1",
"type": "SetVariable",
"dependsOn": [],
"userProperties": [],
"typeProperties": {
"variableName": "start_time",
"value": {
"value": "#utcnow()",
"type": "Expression"
}
}
},
{
"name": "Wait1",
"type": "Wait",
"dependsOn": [
{
"activity": "Set variable1",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"waitTimeInSeconds": 5
}
},
{
"name": "Set variable2",
"description": "",
"type": "SetVariable",
"dependsOn": [
{
"activity": "Wait1",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"variableName": "end_time ",
"value": {
"value": "#utcnow()",
"type": "Expression"
}
}
}
],
"variables": {
"start_time": {
"type": "String"
},
"end_time ": {
"type": "String"
}
},
"folder": {
"name": "Old Pipelines"
},
"annotations": []
}
}
What am I missing, or what could be the problem with this process?
You are having a "blank space" after the variable name end_time like "end_time "
You can see the difference in my repro:
MyCode VS YourCode
Clearing that would make the execution just fine.
I faced a similar issue when doing a Debug run of one of my pipelines. The error messages for these types of errors are not helpful when running in Debug mode.
What I have found is that if you publish the pipeline and then Trigger a Pipeline Run (instead of a Debug run), you can then go to Monitor Pipeline Runs and it will show you a more useful error message.
Apart from possible blank spaces in variable or parameter names, Data Factory doesn't like hyphens, but only in parameter names, variables are fine.
Validation passes, but then in debug time you get the same cryptic error
I ran into this same error message in Data Factory today on the Copy activity. Everything passed validation but this error would pop on each debug run.
I have parameters configured on my dataset connections so that I can use dynamic queries against the data sources. In this case, I was using explicit queries, so the parameters appeared irrelevant. I tried with both blank values and value is null. Both failed the same way.
I tried with stupid but real text values and it worked! The pipeline isn't leveraging the stupid values for any work, so their content doesn't matter, but some portion of the engine needs a non-null value in the parameters in order to execute.

Objects in array is not well supported error observed for ELK docker image

I'm using the latest elk image for kibana dashboard and I have json file which is having list of array[] and I'm not able to show those as field in kibana and It's showing that the object in array is not well supported error message.
As per the document in kibana I just went through the below link but I didn't find anything useful for elk docker image.
https://github.com/istresearch/kibana-object-format
I just tried to run the command
Run bin/kibana-plugin install <package.zip>
but it returned as run is unknown command removed run and ran remaining command but It says that's invalid.
I'm using linux box and Kibana 7.3 version.
Is it possible to overcome this issue? how to deploy that plugin for elk image else is there any other way to make those arrays object as fields in kibana.
I'm not sure how can I proceed. Please help me.
Sample Data:
{
"expand": "schema,names",
"startAt": 0,
"maxResults": 50,
"total": 4,
"issues": [{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "1999875",
"self": "https://amazon.kindle.com/jira/rest/api/2/issue/1999875",
"key": "KINDLEAMZ-67578",
"fields": {
"summary": "contingency is displaying for confirmed card.",
"priority": {
"name": "P1",
"id": "1"
},
"created": "2019-09-23T11:25:21.000+0000"
}
},
{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "2019428",
"self": "https://amazon.kindle.com/jira/rest/api/2/issue/2019428",
"key": "KINDLEAMZ-68661",
"fields": {
"summary": "card",
"priority": {
"name": "P1",
"id": "1"
},
"created": "2019-09-23T11:25:21.000+0000"
}
},
{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "2010958",
"self": "https://amazon.kindle.com/jira/rest/api/2/issue/2010958",
"key": "KINDLEAMZ-68167",
"fields": {
"summary": "Test Card",
"priority": {
"name": "P1",
"id": "1"
},
"created": "2019-09-23T11:25:21.000+0000"
}
}
]
}
I just want to fetch KEY, Summary, Priority from each of the above array. But its not working as expected when I tried to make a field its showing as array in kibana. If this is not working with 7.3.0 should I downgrade to lower version? the steps are missing for docker user in that document. Is there any way to get those details?
Checking here: https://github.com/istresearch/kibana-object-format/releases it looks like the plugin latest release was for Elasticsearch 6.3. I guess that is the reason for your error.
I'm not sure there's a fix for this in kibana. There are many issues on this subject, open for a long time, like: https://github.com/elastic/kibana/issues/3333.

How do I know which rule is active or inactive with sonarqube web api?

all.
I use sonarqube webapi /api/rules/show?key=squid:S4087&actives=true to get detailed information about a rule. The result is json format data, which field present the rule is active or inactive. Anyone can help? I want to know if the rule is active or inactive, is there any other way to do this?
Sonarqube version is Version 6.7 (build 33306).
You can use the following:
api/rules/search?rule_key=squid:S4087&f=actives
Result is:
{
"total": 1,
"p": 1,
"ps": 100,
"rules": [
{
"key": "squid:S4087",
"type": "CODE_SMELL"
}
],
"actives": {
"squid:S4087": [
{
"qProfile": "AWWHfPzOrB_d62qUtqCX",
"inherit": "NONE",
"severity": "MINOR",
"params": [],
"createdAt": "2018-08-29T23:00:39+0200"
}
]
},
"qProfiles": {
"AWWHfPzOrB_d62qUtqCX": {
"name": "Sonar way",
"lang": "java",
"langName": "Java"
}
}
}

Jira Trigger plugin for Jenkins: Obtaining Value from issue object

I'm trying to set up some automation using Jenkins and Jira Trigger plugin for Jenkins. I've set up a web hook at Jira side which is able to invoke build on Jenkins as desired.
I've a trouble with obtaining value for a custom field from incoming Jira request.
I'm trying to use "Issue Attribute Path" feature and I've also referred to post (How to use the 'Issue attribute path' in the parameter mapping of jenkins-trigger-plugin)
Howevevr I'm still unable to get value for custom fields customfield_10010, customfield_10011. I've tried with mapping like fields.customfield_10010, fields.customfield_10010.value, fields.customfield_10010.0.value,customfield_10010.0.value and similar combinations. I'm able to get value for other standard fields as suggested in plugin help. ex: status.name, description etc.
I could not get any clue from Jira documentation site either.
Parts of incoming json data is below for easy reference.
"issue": {
"id": "1000x",
"self": "http://localhost:3080/rest/api/2/issue/10007",
"key": "ABC-2",
"fields": {
"issuetype": {
..
},
"parent": {
..
},
"components": [
],
"timespent": null,
"timeoriginalestimate": 28800,
"description": ".....",
"project": {
..
},
"customfield_10010": [
{
"self": "http://localhost:3080/rest/api/2/customFieldOption/10019",
"value": "ABC-Custom 1",
"id": "10019"
}
],
"fixVersions": [
],
"customfield_10011": [
{
"self": "http://localhost:3080/rest/api/2/customFieldOption/10021",
"value": "ABC-Custom 2",
"id": "10021"
}
],
.....
....
....
}
}
You can get the value of a custom field with the following syntax:
fields.find { it.id == "customfield_10010" }.value
I had the same problem and found this solution here:
https://issues.jenkins-ci.org/browse/JENKINS-13216

Resources