Jenkins管道准备xcodeBuild步骤失败



我创建了一个自由风格的作业,用于为我的一个项目生成.ipa。它工作良好,并成功生成。ipa文件。

现在我想用pipeline创建相同的作业。因此,我将这个自由风格的作业转换为管道作业。但是给了我错误。然后,我使用管道语法一步一步地从我的自由风格的作业生成脚本。但是它仍然给我一个错误。

我搜索了很多,但没有帮助。此外,我试图在xcode构建步骤开始之前解锁钥匙链。但结果还是一样的。

如果有人能帮我解决这个问题,那就太好了。谢谢你。下面是我的管道脚本

node {
stage(‘Code Fetch’) { 
git branch: 'development', changelog: false, credentialsId: 'e7f0318c-0000-0000-0000-a5a3831b2274', poll: false, url: 'https://github.com/XXXXX/XXXXXXX.git'
}
stage("Installing pods") {
sh '/usr/local/bin/pod install'
}
stage("Build") {
sh '''security unlock-keychain -p apple /Users/xxxxxx/Library/Keychains/login.keychain-db
security set-keychain-settings -t 3600 -l /Users/xxxxxx/Library/Keychains/login.keychain-db'''
xcodeBuild appURL: '', assetPackManifestURL: '', buildDir: '', buildIpa: false, bundleID: '', bundleIDInfoPlistPath: '', cfBundleShortVersionStringValue: '', cfBundleVersionValue: '', cleanResultBundlePath: false, compileBitcode: false, configuration: 'Debug', copyProvisioningProfile: false, developmentTeamID: ‘XXXXXXXXX’, developmentTeamName: '', displayImageURL: '', fullSizeImageURL: '', generateArchive: true, ipaExportMethod: 'development', ipaName: ‘My’App, ipaOutputDirectory: 'artifacts', keychainId: '', keychainPath: '', keychainPwd: '', logfileOutputDirectory: '', provisioningProfiles: [[provisioningProfileAppId: 'com.myapp.app', provisioningProfileUUID: '955246fe-0000-0000-0000-cfa12fa742a7']], resultBundlePath: '', sdk: '', signingMethod: 'manual', symRoot: '', target: '', thinning: '', uploadBitcode: false, uploadSymbols: false, xcodeProjectFile: '', xcodeProjectPath: '', xcodeSchema: ‘MyApp’, xcodeWorkspaceFile: 'MyApp', xcodebuildArguments: ''
}

}

和我从jenkins得到的错误:

java.lang.ClassCastException: class au.com.rayh.XCodeBuilder.setKeychainPwd() expects class hudson.util.Secret but received class java.lang.String
at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:492)
at org.jenkinsci.plugins.structs.describable.DescribableModel.injectSetters(DescribableModel.java:429)
at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:331)
Caused: java.lang.IllegalArgumentException: Could not instantiate {appURL=, assetPackManifestURL=, buildDir=, buildIpa=false, bundleID=, bundleIDInfoPlistPath=, cfBundleShortVersionStringValue=, cfBundleVersionValue=, cleanResultBundlePath=false, compileBitcode=false, configuration=Debug, copyProvisioningProfile=false, developmentTeamID=XXXXXXX, developmentTeamName=, displayImageURL=, fullSizeImageURL=, generateArchive=true, ipaExportMethod=development, ipaName=MyApp, ipaOutputDirectory=artifacts, keychainId=, keychainPath=, keychainPwd=, logfileOutputDirectory=, provisioningProfiles=[{provisioningProfileAppId=com.MyApp.app, provisioningProfileUUID=955246fe-0000-0000-0000-cfa12fa742a7}], resultBundlePath=, sdk=, signingMethod=manual, symRoot=, target=, thinning=, uploadBitcode=false, uploadSymbols=false, xcodeProjectFile=, xcodeProjectPath=, xcodeSchema=MyApp, xcodeWorkspaceFile=MyApp, xcodebuildArguments=} for au.com.rayh.XCodeBuilder
at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:334)
at org.jenkinsci.plugins.structs.describable.UninstantiatedDescribable.instantiate(UninstantiatedDescribable.java:208)
at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:466)
at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:409)
at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:329)
Caused: java.lang.IllegalArgumentException: Could not instantiate {delegate=@xcodeBuild(appURL=,assetPackManifestURL=,buildDir=,buildIpa=false,bundleID=,bundleIDInfoPlistPath=,cfBundleShortVersionStringValue=,cfBundleVersionValue=,cleanResultBundlePath=false,compileBitcode=false,configuration=Debug,copyProvisioningProfile=false,developmentTeamID=XXXXXXX,developmentTeamName=,displayImageURL=,fullSizeImageURL=,generateArchive=true,ipaExportMethod=development,ipaName=myapp,ipaOutputDirectory=artifacts,keychainId=,keychainPath=,keychainPwd=,logfileOutputDirectory=,provisioningProfiles=[{provisioningProfileAppId=com.MyApp.app, provisioningProfileUUID=955246fe-0000-0000-0000-cfa12fa742a7}],resultBundlePath=,sdk=,signingMethod=manual,symRoot=,target=,thinning=,uploadBitcode=false,uploadSymbols=false,xcodeProjectFile=,xcodeProjectPath=,xcodeSchema=MyApp,xcodeWorkspaceFile=MyApp,xcodebuildArguments=)} for org.jenkinsci.plugins.workflow.steps.CoreStep
at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:334)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:302)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeDescribable(DSL.java:499)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:196)
at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1278)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1172)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810)
at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46)
at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1278)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1172)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
Caused: java.lang.IllegalArgumentException: Failed to prepare xcodeBuild step
at org.jenkinsci.plugins.workflow.cps.DSL.invokeDescribable(DSL.java:501)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:196)
at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1278)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1172)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810)
at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46)
at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1278)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1172)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
at WorkflowScript.run(WorkflowScript:12)
at ___cps.transform___(Native Method)
at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:86)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:83)
at jdk.internal.reflect.GeneratedMethodAccessor221.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.dispatch(CollectionLiteralBlock.java:55)
at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.item(CollectionLiteralBlock.java:45)
at jdk.internal.reflect.GeneratedMethodAccessor190.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
at com.cloudbees.groovy.cps.Next.step(Next.java:83)
at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:185)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:403)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:97)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:315)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:279)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Finished: FAILURE

最后我得到了解决方案,并能够生成。ipa文件。

管道脚本

node {
stage("Fetching repo") { 
git branch: 'development', changelog: false, credentialsId: ‘xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx’, poll: false, url: 'YOUR-REPO-URL.git'
}
stage("Installing pods") {
sh '/usr/local/bin/pod install'
}
stage("Archive") {
xcodeBuild appURL: '', assetPackManifestURL: '', buildDir: '', buildIpa: true, bundleID: '', bundleIDInfoPlistPath: '', cfBundleShortVersionStringValue: '', cfBundleVersionValue: '', cleanResultBundlePath: false, compileBitcode: false, configuration: 'Debug', copyProvisioningProfile: false, developmentTeamID: ‘XXXXXXXXXX’, developmentTeamName: '', displayImageURL: '', fullSizeImageURL: '', generateArchive: true, ipaExportMethod: 'development', ipaName: ‘IPAName’, ipaOutputDirectory: 'artifacts', logfileOutputDirectory: '', provisioningProfiles: [[provisioningProfileAppId: 'com.myapp.app', provisioningProfileUUID: ‘xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx’]], resultBundlePath: '', sdk: '', signingMethod: 'manual', symRoot: '', target: '', thinning: '', uploadBitcode: false, uploadSymbols: false, xcodeProjectFile: '', xcodeProjectPath: '', xcodeSchema: ‘myapp, xcodeWorkspaceFile: ‘myapp’, xcodebuildArguments: '-destination 'generic/platform=iOS''
}   
stage("Export") {
sh 'xcodebuild -exportArchive -archivePath ${WORKSPACE}/build/Debug-iphoneos/myappxcarchive -exportPath ${JENKINS_HOME}/jobs/${JOB_NAME}/builds/${BUILD_NUMBER}/archive -exportOptionsPlist ${WORKSPACE}/build/Debug-iphoneos/artifacts/myapp.plist'
}
}

最新更新