2016-11-07 11 views
1

私はGroovyを初めて使い、現在Jenkinsサーバーを1.6から2.7に更新しようとしています。私が移行する必要があるのは、バージョン管理のJob DSLです。新しいサーバーでGroovyが欠けているパッケージを見つける:com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentialsパッケージが見つからない、Jenkins Job DSLプラグイン

私がしようとすると、古いジョブDSLを実行したときに、私は以下のエラーを取得:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: 
/apps/Jenkins/workspace/DSL-infrastructure/shared/Shared.groovy: 10: Apparent variable 'com' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes: 
You attempted to reference a variable in the binding or an instance variable from a static context. 
You misspelled a class name or statically imported field. Please check the spelling. 
You attempted to use a method 'com' but left out brackets in a place not allowed by the grammar. 
@ line 10, column 17. 
     def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
       ^

は基本的に、私は問題がグルーヴィーなスクリプトがcom.cloudbeesを見つけることができないということだと思います...パッケージ。

Shared.groovyスクリプトセクション:

static def getCred(partialName) { 
    def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
     com.cloudbees.plugins.credentials.common.StandardUsernameCredentials.class, 
     jenkins.model.Jenkins.instance, 
     null, 
     null 
    ) 
    creds.find { it.description.contains(partialName) } 
    } 

に私はハイとローで検索しましたし、私の人生のためになぜか、どのようにこの欠落しているパッケージの問題を解決するにはを把握することはできません。私がJenkinsをApache Tomcatの中で動かしていると、複雑になります。

この欠落しているパッケージをJenkinsを実行しているApache Tomcatサーバーにインポートする方法がわかりません。私は、ディレクトリ内の.jarファイルが見つかり:

/apps/jenkins/plugins/credentials/WEB-INF/lib/credentials.jar 

を私が参照しようとしている特定のクラス:

https://github.com/jenkinsci/credentials-plugin/blob/master/src/main/java/com/cloudbees/plugins/credentials/CredentialsProvider.java

任意の助けを大幅にバージョンの1.43以来

答えて

0

をいただければ幸いですジョブDSLプラグイン、Credentialsプラグインのクラスは、DSLスクリプトでは使用できなくなりました。したがって、おそらくJenkinsを更新するときにJob DSLプラグインも更新されました。

Credentials pluginのバージョン1.21以降では、資格情報のカスタムIDを指定できるため、説明で資格情報を見つける必要はありません。代わりに説明的なIDを使用してください。

+0

お返事ありがとうございます。私はJob DSLを書き直す必要があると感じていました。私はそれをつかまえて、私が答えを出すなら、ここに答えを掲示します。 –

+0

Credentialsプラグインだけでどのように動作するかの例を表示できますか? – misha

0

daspilkerのように既に定義されたJenkinsグローバルcredentialsを使用できるようにするCredential Bindingプラグインを使用する方法があります。 以下は、SVN urlからフォルダ構造をリストしているジョブの例です(他のreposと同様に動作します)。 は秘密を連結する必要があることに注意してください。フォーマッタを使用すると、それを隠すことになり、認識されません(簡単にするためにユーザの下には連結されません)。

Jenkins Secrets

関連する問題