|  | 
| 14 | 14 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" | 
| 15 | 15 | . $scriptroot/pipeline-logging-functions.sh | 
| 16 | 16 | 
 | 
|  | 17 | + | 
|  | 18 | +# replace all special characters with _, some builds use special characters like : in Agent.Jobname, that is not a permissible name while uploading artifacts. | 
|  | 19 | +artifact_name=$SYSTEM_STAGENAME"_"$AGENT_JOBNAME"_SBOM" | 
|  | 20 | +safe_artifact_name="${artifact_name//["/:<>\\|?@*$" ]/_}" | 
| 17 | 21 | manifest_dir=$1 | 
| 18 | 22 | 
 | 
| 19 |  | -if [ ! -d "$manifest_dir" ] ; then | 
| 20 |  | -  mkdir -p "$manifest_dir" | 
| 21 |  | -  echo "Sbom directory created." $manifest_dir | 
|  | 23 | +# Normally - we'd listen to the manifest path given, but 1ES templates will overwrite if this level gets uploaded directly | 
|  | 24 | +# with their own overwriting ours. So we create it as a sub directory of the requested manifest path. | 
|  | 25 | +sbom_generation_dir="$manifest_dir/$safe_artifact_name" | 
|  | 26 | + | 
|  | 27 | +if [ ! -d "$sbom_generation_dir" ] ; then | 
|  | 28 | +  mkdir -p "$sbom_generation_dir" | 
|  | 29 | +  echo "Sbom directory created." $sbom_generation_dir | 
| 22 | 30 | else | 
| 23 | 31 |   Write-PipelineTelemetryError -category 'Build'  "Unable to create sbom folder." | 
| 24 | 32 | fi | 
| 25 | 33 | 
 | 
| 26 |  | -artifact_name=$SYSTEM_STAGENAME"_"$AGENT_JOBNAME"_SBOM" | 
| 27 | 34 | echo "Artifact name before : "$artifact_name | 
| 28 |  | -# replace all special characters with _, some builds use special characters like : in Agent.Jobname, that is not a permissible name while uploading artifacts. | 
| 29 |  | -safe_artifact_name="${artifact_name//["/:<>\\|?@*$" ]/_}" | 
| 30 | 35 | echo "Artifact name after : "$safe_artifact_name | 
| 31 | 36 | export ARTIFACT_NAME=$safe_artifact_name | 
| 32 | 37 | echo "##vso[task.setvariable variable=ARTIFACT_NAME]$safe_artifact_name" | 
|  | 
0 commit comments