2017-02-14 4 views
0

Lockable Resource Pluginを使用して、ジョブの特定の部分が同時に実行されないようにしています。私はジョブを開始し、 "入力ステップ"を使用して入力パラメータを収集し、ブロックするロックがクリアされるのを待っている間に待ち行列を作ってから進めたいと考えています。代わりに、ロックブロックの外側に入力ステップがあっても、すべてのロックがクリアされるまで、ジョブ全体がブロックされ、入力を許可しません。ロックプラグインを使用した入力ステップ後のキュージョブ

私は間違っていますか?ここで

は一例です:

// Define an input step and capture the outcome from it. 
def outcome = input id: 'deployment', 
    message: 'Deployment Configuration', 
    ok: 'Deploy', 
    parameters: [ 
    [ 
     $class  : 'hudson.model.ChoiceParameterDefinition', choices: "development", 
     name  : 'stack', 
     description: 'select a stack to deploy' 
    ], 
    [ 
     $class  : 'hudson.model.ChoiceParameterDefinition', choices: "choice1\nchoice2", 
     name  : 'profile', 
     description: 'select a profile to deploy' 
    ], 
    ] 

def profile = "${outcome.get('profile')}" 
def stack = "${outcome.get('stack')}" 

echo "profile: ${profile}" 
echo "stack: ${stack}" 

// use lockable resource to prevent multiple jobs of the same project from running at the same time. 
lock(resource: "deployment") { 
    sh "echo running deployment script here." 
} 

答えて

0

この記事Jenkins Pipeline: “input” step blocks executor 後、私は私のブロックの周り

stage('deploy') { 
} 

を追加することで問題を解決することができました。例えば。

// Define an input step and capture the outcome from it. 
def outcome = input id: 'deployment', 
    message: 'Deployment Configuration', 
    ok: 'Deploy', 
    parameters: [ 
    [ 
     $class  : 'hudson.model.ChoiceParameterDefinition', choices: "development", 
     name  : 'stack', 
     description: 'select a stack to deploy' 
    ], 
    [ 
     $class  : 'hudson.model.ChoiceParameterDefinition', choices: "choice1\nchoice2", 
     name  : 'profile', 
     description: 'select a profile to deploy' 
    ], 
    ] 

def profile = "${outcome.get('profile')}" 
def stack = "${outcome.get('stack')}" 

stage('deploy') { 
    echo "profile: ${profile}" 
    echo "stack: ${stack}" 

    // use lockable resource to prevent multiple jobs of the same project from running at the same time. 
    lock(resource: "deployment") { 
    sh "echo running deployment script here." 
    } 
} 
関連する問題