我想修改package.json文件中的version值,但是出现如下错误。我可以读取version,但是在修改version值时出现如下错误。如何解决?
org.kohsuke.stapler.NoStaplerConstructorException: There's no @DataBoundConstructor on any constructor of class java.lang.String
at org.kohsuke.stapler.ClassDescriptor.loadConstructorParamNames(ClassDescriptor.java:288)
at org.jenkinsci.plugins.structs.describable.DescribableModel.<init>(DescribableModel.java:153)
at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:474)
at org.jenkinsci.plugins.structs.describable.DescribableModel.injectSetters(DescribableModel.java:429)
at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:331)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:305)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:196)
at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:124)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:47)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
Caused: java.lang.IllegalArgumentException: Could not instantiate {file={name=demo, version=0.0.0-alpha.0, dependencies={@testing-library/jest-dom=^5.16.5, @testing-library/react=^13.4.0, @testing-library/user-event=^13.5.0, react=^18.2.0, react-dom=^18.2.0, react-scripts=5.0.1, web-vitals=^2.1.4}, scripts={start=react-scripts start, build=react-scripts build, test=react-scripts test, eject=react-scripts eject, sonar-scanner=node_modules/sonar-scanner/bin/sonar-scanner}, eslintConfig={extends=[react-app, react-app/jest]}, browserslist={production=[>0.2%, not dead, not op_mini all], development=[last 1 chrome version, last 1 firefox version, last 1 safari version]}, description=## Available Scripts, main=index.js, repository={type=git, url=git+ssh://git@gitlab.com/***.git}, keywords=[**, Demo, UI], publishConfig={registry=http://****/repository/npm-private/}}} for org.jenkinsci.plugins.pipeline.utility.steps.json.WriteJSONStep
at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:334)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:305)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:196)
at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:124)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:47)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
groovy文件中的代码:
def updateProjectPackage(params) {
packageFile = readJSON(file: 'package.json')
//params.appVersion = 0.0.0-alpha.0
packageFile.version = params.appVersion
writeJSON file: packageFile
}
包.json
{
"name": "demo",
"version": "0.1.0"
}
1条答案
按热度按时间hivapdat1#
您的
writeJSON
部分似乎不对。它应该是这样的。