I have plenty of bash scripts with various variables that being piped into various scripts.
I've been wondering if I can extract an output of bash script that is activated by Azure Pipeline to be a pipeline variable for the rest of the Pipeline runtime?
Example:
foo=$(date + %Y%m%d_%H%M%S) output: 20200219_143400, I'd like to get the output for later use on the pipeline.
Depends on how you design your pipeline you can use Azure Pipeline variables:
- job: Job1
steps:
- bash: |
$WORKDIR/foo.sh
echo "##vso[task.setvariable variable=foo]$foo"
name: FooStep
- bash: |
$WORKDIR/nextscript.sh $(FooStep.foo)
name: NextScript
# ...
- job: Job1
steps:
- bash: |
$WORKDIR/foo.sh
echo "##vso[task.setvariable variable=foo;isOutput=true]$foo"
name: FooStep
- job: Job2
dependsOn: Job1
variables:
outputFooStepFoo: $[ dependencies.Job1.outputs['FooStep.foo'] ]
steps:
- bash: |
$WORKDIR/job2script.sh $(outputFooStepFoo)
name: Job2ScriptStep
# ...
So, you need to "print to pipeline console" with ##vso[task.setvariable] all variables you need to save to output, and after to pass them as scripts arguments values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With