2017-06-13 4 views
5

जेनकींस पाइपलाइन जहां प्रत्येक चरण एक अलग एजेंट पर चलता है का उपयोग करते समय good practice है शुरुआत में agent none उपयोग करने के लिए:एकाधिक एजेंटों पर जेनकींस पाइपलाइन के साथ पोस्ट चरणों का उपयोग कैसे करें?

pipeline { 
    agent none 
    stages { 
    stage('Checkout') { 
     agent { label 'master' } 
     steps { script { currentBuild.result = 'SUCCESS' } } 
    } 
    stage('Build') { 
     agent { label 'someagent' } 
     steps { bat "exit 1" } 
    } 
    } 
    post { 
    always { 
     step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "[email protected]", sendToIndividuals: true]) 
    } 
    } 
} 

लेकिन ऐसा करने से करने के लिए Required context class hudson.FilePath is missing त्रुटि संदेश जाता है जब ईमेल बाहर जाना चाहिए:

[Pipeline] { (Declarative: Post Actions) 
[Pipeline] step 
Required context class hudson.FilePath is missing 
Perhaps you forgot to surround the code with a step that provides this, such as: node 
[Pipeline] error 
[Pipeline] } 

जब मैं agent none से agent any में बदलता हूं, तो यह ठीक काम करता है।

agent any का उपयोग किये बिना post काम करने के लिए चरण कैसे प्राप्त कर सकता हूं?

उत्तर

6

step कि एक node चरण में डाक करता लपेट:

post { 
    always { 
    node('awesome_node_label') { 
     step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "[email protected]", sendToIndividuals: true]) 
    } 
    } 
} 
+0

मैं 'नोड ('मास्टर')' इस्तेमाल किया और अब यह काम करता है। धन्यवाद। अगर मैं लेबल छोड़ देता हूं, तो मुझे त्रुटि मिलती है 'वर्कफ़्लोस्क्रिप्ट: 15: आवश्यक पैरामीटर गुम है: "लेबल" '। क्या आप अपना उत्तर समायोजित कर सकते हैं? –

+0

यकीन है, धन्यवाद! – burnettk

+0

इससे पहले कि मैंने इस सवाल से पूछा, मैंने 'पोस्ट' के ठीक बाद 'नोड' का उपयोग करने की कोशिश की, जिसकी अनुमति नहीं है, लेकिन यह केवल 'चरण' को लपेटने के लिए कभी नहीं हुआ। आपकी सहायता के लिए धन्यवाद. –

संबंधित मुद्दे