jenkins declerative pipeline - fail build when coverage drops - jenkins

using declerative pipeline syntax in a Jenkinsfile and publishing coverage report using cobertura as follows
cobertura(
coberturaReportFile: 'coverage/cobertura-coverage.xml',
enableNewApi: true,
autoUpdateHealth: true,
autoUpdateStability: true,
failUnstable: true,
failUnhealthy: true,
failNoReports: true,
onlyStable: false
)
also tried using code coverage api as follows:
publishCoverage(
failUnhealthy: true,
calculateDiffForChangeRequests: true,
failBuildIfCoverageDecreasedInChangeRequest: true,
failNoReports: true,
adapters: [
coberturaAdapter(path: 'coverage/cobertura-coverage.xml')
]
)
looking at all the documentation i could find, i wasn't able to figure out what are the instructions to fail the build if coverage drops without using hard-coded thresholds.
would appreciate a reference or a code snippet.

enabling autoUpdateHealth in conjunction with hard-coded threshold would do the trick
cobertura(
coberturaReportFile: 'coverage/cobertura-coverage.xml',
enableNewApi: true,
autoUpdateHealth: true,
autoUpdateStability: true,
failUnstable: true,
failUnhealthy: true,
failNoReports: true,
onlyStable: false
conditionalCoverageTargets: '80, 0, 0',
fileCoverageTargets: '80, 0, 0',
lineCoverageTargets: '80, 0, 0',
methodCoverageTargets: '80, 0, 0',
packageCoverageTargets: '80, 0, 0',
)

Related

The editor auto-complete function of NEO4J 4.4 is not working

The editor auto-complete functionality of NEO4J is not working although the config setting is set to "true"
config editorAutocomplete:true
{
"maxHistory": 30,
"theme": "auto",
"initCmd": ":play start",
"playImplicitInitCommands": true,
"initialNodeDisplay": 300,
"maxNeighbours": 100,
"showSampleScripts": true,
"browserSyncDebugServer": null,
"maxRows": 1000,
"maxFieldItems": 500,
"autoComplete": true,
"scrollToTop": true,
"maxFrames": 15,
"codeFontLigatures": true,
"useBoltRouting": false,
"editorLint": false,
"enableMultiStatementMode": true,
"connectionTimeout": 30000,
"showPerformanceOverlay": false,
"allowCrashReports": true,
"allowUserStats": true,
"showWheelZoomInfo": true,
"useCypherThread": true,
# **"editorAutocomplete": true**
This is set to true by default for the NEO4J browser, however it is not working in NEO4J 4.4 as it did in NEO4J 3.2.
I tried to change the setting, but it had no effect. I refreshed the browser and still nothing.

How to use nested maps in Dart?

I am trying to use Dart alongside a api for a school system i have reverse engineered and I'm trying to implement it in a library, when using dio to send a request it is converted to a map (the output of the api is json i think) but it is nested and I’m not sure on how to work with them.
This is the code i have written
class StudentClient{
String sessionID;
StudentClient(this.sessionID);
Future<Map> basicInfo() async {
var dio = Dio();
dio.options.headers["Authorization"] = "Basic $sessionID";
Response loginRequest = await dio.get(
'https://www.classcharts.com/apiv2student/ping',
options: Options(contentType: Headers.formUrlEncodedContentType),
);
assert(loginRequest.data is Map);
Map<dynamic, dynamic> request = loginRequest.data;
return request;
}
and the (censored) output
{success: 1, data: {user: {id: 696969, name: Foo Bar, first_name: Foo, last_name: Bar, avatar_url: https://asdsdsdsd/26.0.0/img/faces/default.png, display_behaviour: true, display_parent_behaviour: false, display_homework: true, display_rewards: true, display_detentions: true, display_report_cards: true, display_classes: false, display_announcements: true, display_attendance: false, display_attendance_type: none, display_attendance_percentage: true, display_activity: true, display_mental_health: false, display_mental_health_no_tracker: false, display_timetable: true, is_disabled: false, display_two_way_communications: true, display_absences: false, can_upload_attachments: false, display_event_badges: false, display_avatars: false, display_concern_submission: false, display_custom_fields: false, pupil_concerns_help_text: , allow_pupils_add_timetable_notes: false, detention_alias_plural_uc: Detentions, announcements_count: 0, messages_count: 0, pusher_channel_name: Pupil_dfghfghhghfghfghfghfghfghfghfghfghfgh, has_birthday: true, has_new_survey: false, survey_id: null}}, meta: {version: 26.0.0}}
Any help would be appreciated!

Electron allows `require('path')` in renderer even when `nodeIntegration` is set to `false`

My understanding is that setting nodeIntegration to false will block access to Node modules in the renderer process. But I'm able to do require('path') in spite of having nodeIntegration set to false.
Is my understanding not correct?
If my understanding is correct but path is given an exception, I wonder if there are other modules given the same exception?
Here's my BrowserWindow options
mainWindow = new BrowserWindow({
webPreferences: {
// The below configurations are set to achieve the maximum
// security possible in Electron
contextIsolation: true,
webSecurity: true,
enableRemoteModule: false,
nodeIntegration: false,
nodeIntegrationInSubFrames: false,
nodeIntegrationInWorker: false,
allowRunningInsecureContent: false,
sandbox: true,
preload: join(__dirname, "preload.js"),
},
center: true,
title: "Orange",
minWidth: 800,
minHeight: 600,
});

How to use Jenkins P4 plugin publish for declarative pipeline

stage('Publish Assets')
{
when{
expression { //some condition }
}
steps{
p4publish(
credential: 'abcd',
publish: [$class: 'SubmitImpl', delete: false, description: 'Submitted by Jenkins. Build: ${BUILD_TAG}', onlyOnSuccess: true, purge: '', reopen: false],
workspace: [$class: 'ManualWorkspaceImpl', charset: 'none', name: 'jenkins-abcd-publish', pinHost: false, spec: [allwrite: true, backup: false, clobber: false, compress: false, line: 'LOCAL', locked: false, modtime: false, rmdir: false, serverID: '', streamName: '//abcd/efg', type: 'WRITABLE', view: '']])
}
}
I tried a couple of things and placing it under script block as well but no luck. Is it not suppose to work with declarative pipelines or am I missing something? It would be nice if I could get some help on this
Found this guide in the P4 plugin repo that might help. They seem to suggest using the snippet generator to help with getting the syntax correct. The examples they show are written with the imperative syntax, but I don't see why it wouldn't work for declarative.
node {
stage('Sync') {
// sync files from //streams/st1-main/...
p4sync(charset: 'none',
credential: 'phooey1666',
populate: [$class: 'AutoCleanImpl',
delete: true,
modtime: false,
pin: '',
quiet: true,
replace: true],
stream: '//streams/st1-main')
}
}
p4 publish https://github.com/jenkinsci/p4-plugin/blob/master/WORKFLOW.md#using-standard-freestyle-jobs-steps
p4publish(credential: 'phooey1666',
publish: [$class: 'SubmitImpl',
delete: false,
description: 'Submitted by Jenkins. Build: ${BUILD_TAG}',
onlyOnSuccess: false,
purge: '',
reopen: false],
workspace: [$class: 'StreamWorkspaceImpl',
charset: 'none',
format: 'jenkins-${NODE_NAME}-${JOB_NAME}-publish',
pinHost: false,
streamName: '//streams/st2-rel1'])
https://github.com/jenkinsci/p4-plugin/blob/master/WORKFLOW.md

VSCode always trim trailing space (or format) on save

My vscode always format js code on save, here is my settings, but it didn't work:
"editor.insertSpaces": true,
"editor.renderWhitespace": "none",
"typescript.check.workspaceVersion": false,
"window.zoomLevel": 1,
"editor.cursorStyle": "block",
"typescript.check.tscVersion": false,
"editor.cursorBlinking": "blink",
"editor.lineNumbers": "relative",
"workbench.activityBar.visible": false,
"vim.useCtrlKeys": false,
"files.trimTrailingWhitespace": false,
"editor.trimAutoWhitespace": false,
"eslint.autoFixOnSave": false,
"editor.formatOnSave": false
Something wrong?

Resources