2017-05-29 17 views
0

私はジェンキンスのパイプラインを使用していますシンプルなグルーヴィーなスクリプトを持っていると奇妙な例外の種類と操作をマージgitのに失敗します。ジェンキンスパイプラインgroovy.lang.MissingPropertyException

スクリプト:

node("master") { 
ws(env.BUILD_NUMBER.toString()) { // workspace 
    withCredentials([ 
     [$class: 'UsernamePasswordBinding', credentialsId: 'bitbucket', variable: 'BITBUCKET_AUTH'], 
     [$class: 'UsernamePasswordBinding', credentialsId: 'bitbucket-https', variable: 'BITBUCKET_HTTPS_AUTH'],]) { 

     def applicationName = env.CUSTOMER_NAME 
     def packageName = "no.bstcm.loyaltyapp.${env.REPO_NAME}" 
     def googleServicesJsonContents = env.GOOGLE_SERVICES_JSON 
     def bitbucketRepoName = "android_loyalty_app_${env.REPO_NAME}" 
     def bitbucketRepoApiUrl = "https://api.bitbucket.org/2.0/repositories/boost-development/${bitbucketRepoName}" 
     def starterBranch = "shopping_mall" 
     def projectPath = "jenkins-project" 

     stage('Create repository on bitbucket') { 
      sh "curl POST -v -u $BITBUCKET_AUTH $bitbucketRepoApiUrl -H 'Content-Type: application/json' -d '{\"is_private\": true, \"project\": {\"key\": \"LOY\"}}'" 
     } 

     stage('Create local repository') { 
      dir(projectPath) { 
       sh "git init" 
       sh "touch README.md" 
       sh "git add README.md" 
       sh "git commit --message='Initial commit'" 
      } 
     } 

     stage('Merge starter') { 
      dir(projectPath) { 
       sh "git init" 
       sh "git remote add starter https://[email protected]/boost-development/app_designer_starter_android.git" 
       sh "git fetch starter" 
       sh "git checkout master" <--- FAILS HERE 
       sh "git remote add origin https://[email protected]/boost-development/$bitbucketRepoName.git" 
       sh "git push -u origin master" 
       sh "git remote remove starter" 
      } 
     } 
    } 
} 

例外私が受け取る(およびパイプラインが壊れた):

[Pipeline] sh 
[jenkins-project] Running shell script 
+ git fetch starter 
From https://bitbucket.org/***/*** 
* [new branch]  master  -> starter/master 
[Pipeline] sh 
[jenkins-project] Running shell script 
+ git checkout master 
Already on 'master' 
Branch master set up to track remote branch master from starter. 
[Pipeline] } 
[Pipeline] // dir 
[Pipeline] } 
[Pipeline] // stage 
[Pipeline] } 
[Pipeline] // withCredentials 
[Pipeline] } 
[Pipeline] // ws 
[Pipeline] } 
[Pipeline] // node 
[Pipeline] End of Pipeline 
groovy.lang.MissingPropertyException: No such property: git for 
class: org.codehaus.groovy.runtime.GStringImpl 
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAd 
apter.java:53) 
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:458) 
at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:243) 
at org.kohsuke.groovy.sandbox.GroovyInterceptor.onGetProperty(GroovyInterceptor.java:52) 
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:308) 
at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:241) 
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:238) 
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:28) 
at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20) 
at WorkflowScript.run(WorkflowScript:36) 
at ___cps.transform___(Native Method) 

君たちは何cができた任意のアイデアを持っていますかこの問題を起こす?私は考えていないし、Googleはここであまり役に立たない。グルーヴィーな文字列のこの種で

答えて

1

トラブル:この場合

sh ".... $bitbucketRepoName.git ...." 

グルーヴィーそれだけでこのそれを変更する変数bitbucketRepoName

のプロパティgitにアクセスしようとする:

sh ".... ${bitbucketRepoName}.git ...." 
+0

ああ神に感謝あなたはそんなに。この構文エラーに気付かず、ジェンキン関連の問題を探すことで、どれくらいの時間を無駄にしたか分かりません。 – Rybzor

関連する問題