PostJobBash
is Bash@3
based task that allows you to executes bash scripts (across platforms) in the post-job
phase of the job!
Note
The PostJobBash
is based on Microsoft's Bash@3
(https://github.com/microsoft/azure-pipelines-tasks/tree/master/Tasks/BashV3) version 3.237.0
therefore supports the same APIs (https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/bash-v3?view=azure-pipelines)
Exiting job
- task: PostJobBash@1
displayName: Exit log
inputs:
targetType: 'inline'
script: |
echo "Exiting the job!"
Clean workspace after the pipeline executes
- task: PostJobBash@1
displayName: Clean workspace
env:
PIPELINE_WORKSPACE: $(Pipeline.Workspace)
AGENT_WORK_FOLDER: $(Agent.WorkFolder)
inputs:
targetType: 'inline'
script: |
pipelineWorkspace=$PIPELINE_WORKSPACE
agentWorkFolder=$AGENT_WORK_FOLDER
if [ -d "$pipelineWorkspace" ]; then
echo "Pipeline workspace folder still exists ($pipelineWorkspace), deleting..."
cd $agentWorkFolder
rm -r $pipelineWorkspace
else
echo "Pipeline workspace folder does not exist."
fi