-
Bug
-
Resolution: Unresolved
-
Major
-
None
How can pipeline 'post' stages be executed in the pipeline agent environment?
In the below, the deleteDir() is executing outside the dockerfile defined container, thus not as root, and will fail to remove any files that were generated inside the container as root.
It appears by default that the post for a specific stage execute in the current agent for that stage, which might be the pipeline agent, but that by default post for the while pipeline execute in a 'none' environment. Is there a method to specify the agent for the whole pipeline post?
pipeline { agent { dockerfile { args '-u root'} } stages { stage('One') { steps { echo 'Do some stuff as root that produce root owned files in workspace' } } stage('Two') { steps { echo 'Do some more stuff' } post { always { echo 'Do some stage specific cleanup' # Executed in the pipeline agent } } } } post { always { deleteDir() # This is not executed in the pipeline agent context } } }
- relates to
-
JENKINS-46831 Not able to use a normal agent on stage when agent docker is declared globally
- Open
-
JENKINS-24440 Jenkins cannot delete root-owned files/folders in jenkins-owned directories
- Open
-
JENKINS-43578 Declarative pipeline: post section doesn't play nice with agent none
- Closed