Configure pod retention value of jenkins kubernetes plugin using groovy - jenkins-plugins

Trying to configure pod retention value for Jenkins Kubernetes plugin using
groovy script.
kubernetes.setPodRetention(org.csanchez.jenkins.plugins.kubernetes.pod.retention.Podretention.Never())
method is failing to configure with below error :
Invalid value provided in main configuration No signature of method: static
org.csanchez.jenkins.plugins.kubernetes.pod.retention.PodRetention.Never()
is applicable for argument types: () values: []
tried configuring by using different values for the method:
kubernetes.setPodRetention(org.csanchez.jenkins.plugins.kubernetes.pod.retention.Never)
Error using the above value as well.
Please someone help me with this as I was struck with this from quite along.
Below is the code:
import java.util.logging.Logger
import hudson.*
import hudson.model.*
import java.io.PrintWriter
import java.io.StringWriter
import jenkins.*
import jenkins.install.InstallState
import jenkins.model.*
import jenkins.util.xml.*
import javax.xml.xpath.*
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.impl.*
import com.cloudbees.plugins.credentials.common.*
import com.cloudbees.plugins.credentials.domains.*
import com.cloudbees.jenkins.plugins.sshcredentials.impl.*
import org.jenkinsci.plugins.plaincredentials.impl.*
import org.jenkinsci.plugins.docker.commons.credentials.*
import org.csanchez.jenkins.plugins.kubernetes.*
import org.csanchez.jenkins.plugins.kubernetes.pod.retention.PodRetention
KubernetesCloud kubernetes = new KubernetesCloud('test')
kubernetes.setServerUrl('http://test_url')
kubernetes.setMaxRequestsPerHostStr(20)
kubernetes.setPodRetention(org.csanchez.jenkins.plugins.kubernetes.pod.retention.PodRetention.Never())
kubernetes.setWaitForPodSec(90)
// documentation reference
https://javadoc.jenkins.io/plugin/kubernetes/
// Method used
setPodRetention(PodRetention podRetention)
Set the global pod retention policy for the plugin.
Can some let me know how to set the pod retention value with values never
, always etc.

You are missing new keyword that is required to create an object. The line
kubernetes.setPodRetention(org.csanchez.jenkins.plugins.kubernetes.pod.retention.PodRetention.Never())
Should be
kubernetes.setPodRetention(new org.csanchez.jenkins.plugins.kubernetes.pod.retention.PodRetention.Never())
To configure global pod retention policy go to https://jenkins_url/configure (or https://jenkins_url/configureClouds in latest lts version of jenkins) and update "Pod Retention" configuration grouped under Kubernetes Cloud

Related

Import error firebase/firestore using react

I have a problem with firestore. I want to read some data from firebase but I can't import collection from firebase Attempted import error: 'collection' is not exported from 'firebase/firestore/'. I read some articles that said this problem is related to v9 SDK.
You have to import the Firebase SDKs correctly. The issue is in the first line where you are importing from "firebase" directly which is not the ideal method and as per my understanding, the import calls/methods are not in sync with the version changes. Be sure to read the documentation on using Firebase with module bundlers
Starting with Firebase v8.0.0, you have to import Firebase SDKs as per the documentation where it is mentioned that there was a breaking change in version 8.0 where
browser fields in package.json files now point to ESM bundles instead
of CJS bundles. Users who are using ESM imports must now use the
default import instead of a namespace import
Before 8.0.0
import * as firebase from 'firebase/app'
After 8.0.0
import firebase from 'firebase/app'
Code that uses require('firebase/app') or require('firebase') will still work, but you should change these require calls to require('firebase/app').default or require('firebase').default
Change your code as shown below :
import firebase from "firebase/app"
import { getFirestore } from "firebase/firestore";
import { collection, addDoc, getDocs } from "firebase/firestore";
import "firebase/auth"
const auth = firebase.auth()
This should work for you. If not, then probably you have updated your SDK version from 8 to 9 and with version 9 things changed a bit for importing firebase, but there is no need to downgrade to a previous version, there is a "compatibility" option so can use the /compat folder in your imports, like this
import firebase from 'firebase/compat/app';
From the Firebase documentation:
In order to keep your code functioning after updating your dependency
from v8 to v9 beta, change your import statements to use the "compat"
version of each import as shown below (v9 compat packages are API
compatible with v8 code) :
import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
import 'firebase/compat/firestore';
That error message means there is no such export "collection" from the module "firebase/firestore/". So the error is on the second line when you are trying to import "collection".
In the docs there is no trailing "/" in "firebase/firestore". Try removing that trailing "/" and try again.
I suggest you follow this guide on setting up firestore

How to import something globally (only once) in a React Project

In my React project, I heavily depend on lodash. Now in each file I have an import statement like this
import each from 'lodash/each';
import compact from 'lodash/compact';
Is there any way in React that I don't need to import these in every file ? Can I import them once in App.jsx (The root component) and they would be available for all React Components that are it's children ?
Or maybe make lodash object globally available throughout the project ?
This is not really recommended, but you could do this in your main file:
import _ from 'lodash';
window._ = _;
to make it available via global window object.
However, it would be better to configure your bundler or compiler setup to expose this as global variable.

what am I doing wrong with this import in my react component?

What am I doing wrong with this import in my react component? I'm trying to use the following npm package in my React app:
https://www.npmjs.com/package/chrome-headless-render-pdf
I'm assuming that this package is useable from a React app. Is there any reason why it would not be? If not then how should I evaluate whether or not an npm package is useable in a React app? The npmjs page shows the package being used like this:
const RenderPDF = require('chrome-headless-render-pdf');
RenderPDF.generateSinglePdf('http://google.com', 'outputPdf.pdf');
I was thinking that I should be able to simply import the package in my React component like this:
import * from 'chrome-headless-render-pdf';
However, intellisense is reporting this import as invalid. How can I properly import this package into my component?
In their documentation, They also mentioned it as:
you can also use it from typescript or es6
import RenderPDF from 'chrome-headless-render-pdf';
RenderPDF.generateSinglePdf('http://google.com', 'outputPdf.pdf');
This line is not a valid import statement according to the ecmascript spec.
import * from 'chrome-headless-render-pdf';
When you use the * import syntax, you must assign a name. For example:
import * as chromeHeadless from 'chrome-headless-render-pdf';
This will make all named exports from the module available from your chosen namespace. You might use this with modules that does not have a default export. Typically the documentation for the module will explain which style of import syntax you can use.
MDN provides a reference of the different valid import statements available

Expo error: Cannot read property 'statusBarHeight' of null

How to fix this error in Expo v34.0.0?
In Expo, you can no longer import directly from 'expo', so change from (the old way):
import { Constants } from 'expo'; // OLD WAY
to (the updated way):
import Constants from 'expo-constants'; // NEW WAY
Similarly, if you are using the following features, use this format:
import MapView from 'react-native-maps';
import * as Location from 'expo-location';
import * as Permissions from 'expo-permissions';
import { DeviceMotion } from 'expo-sensors';
Expo documentation is quite helpful.
If you are using the online Expo editor, you will be prompted to install the packages, so just click OK. Otherwise, run:
expo install expo-constants
Expo separated a lot of their previously joined libraries and Constants is one of them, to get the constants now, follow along:
Install expo-constants by running this on your project directory:
expo install expo-constants
import Constants where needed as follows
import Constants from 'expo-constants';
Retrieve statusBarHeight like this:
const barHeight = Constants.statusBarHeight;
More on the new documentations for Expo SDK 34 can be found here.
Hope this Helps!

ReactJS: IE 10 Compatibility, Set is undefined

I am trying to get ReactJs compatible with IE 10 and have added the following import statements before any other import.
import '#babel/polyfill';
import 'core-js/es6/map';
import 'core-js/es6/set';
The import is done in the index file of my app, App.tsx.
However I am still getting the following error and am unable to resolve it.
SCRIPT5009: 'Set' is undefined
How can I resolve this issue?
I also run in this same issue. To solve this, you need some additional node packages in order to perform polyfills.
Please, 1st install the npm package "core-js". After that, add
import 'core-js/es/set'
import 'core-js/es/map'
If still running into issues, install this other package react-app-polyfill and add the following additional import:
import 'react-app-polyfill/ie9'
These imports must be in the root index file of your project. Hope this helps.

Resources