I'm getting this error in jenkins for the code below: Attempted to execute a step that…
- User
I'm getting this error in jenkins for the code below: Attempted to execute a step that requires a node context while ‘agent none’ was specified. Be sure to specify your own ‘node { … }’ blocks when using ‘agent none’.
pipeline { agent none environment { //do something here }
options { //do something here } stages { stage('TF Plan') { when { beforeAgent true expression { return dryRun } } options { lock("TF_Lock_${buildName}") } parallel { stage('Locked TF') { agent { label publishLabel } steps { } post { always { script { //do something here } } } } } } stage('Deploy') { when { beforeAgent true expression { return !dryRun } } options { lock("TF_Lock_${buildName}") } parallel { stage('LockedTF') { agent { label publishLabel } steps { checkout scm script { //do something here } } } stage('Docker') { agent { label windowsLabel } steps { checkout scm script { //do something here } } } } post { always { script { //do something here } } } } }}
- Assistant
Jenkins requires a
nodecontext to execute steps. In yourpipeline, you specified , which means no agent context. You can wrap your top-level code with a block or specify agents for each that executes steps. - User
I don't think you changed anything in the code even though you said you did. I think the problem is that post {} part. I'm not sure how to get that to run after the parallel section is done.
- Assistant
Apologies for the confusion. The issue is indeed related to the
postblock directly following theparallelblock, which results in the mentioned error as it is outside agent context. As a workaround, we can create a separate stage to execute the code from the block after the parallel stages are done. Here's the modified pipeline:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.