Decorator skipping not working

%3CLINGO-SUB%20id%3D%22lingo-sub-2986476%22%20slang%3D%22en-US%22%3EDecorator%20skipping%20not%20working%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2986476%22%20slang%3D%22en-US%22%3E%3CP%3EI%20developed%20a%20decorator%20based%20on%20Microsoft%20documentation.%20The%20injecting%20part%20is%20working%20as%20expected%20and%20the%20skipping%20part%20is%20not%20working%20as%20expected.%20i%20tried%20it%20multiple%20times%2C%20in%20different%20ways%20according%26nbsp%3B%20to%20documentation%20provided%20by%20Microsoft%20and%20the%20injected%20decorator%20is%20not%20getting%20skipped.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBelow%20is%20the%20method%20i%20followed%20from%20documentation.%20There%20is%20not%20enough%20documentation%20on%20capturing%20the%20decorator%20logs%20can%20you%20please%20advise.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Esteps%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22%22%3E-%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3E%24%7B%7B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3Eif%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3Ene(variables%5B'skipInjecting'%5D%2C%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3E'true'%3C%2FSPAN%3E%3CSPAN%20class%3D%22%22%3E)%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3E%7D%7D%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22%22%3E%26nbsp%3B%20-%20script%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3Eecho%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3EInjected%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3Ethe%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3Edecorator%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eand%20in%20the%20pipeline%20i%20added%20the%20variables%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22%22%3Evariables%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22%22%3E%26nbsp%3B%20skipInjecting%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3Etrue%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22%22%3E%26nbsp%3B%20%26nbsp%3B%20steps%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22%22%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B-%20script%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3Eecho%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3EThis%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3Eis%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3Ethe%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3Eonly%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3Estep.%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3ENo%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3Edecorator%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3Eis%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3Eadded.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20used%20the%20same%20syntax%20from%20the%20Microsoft%20Documentation.%26nbsp%3B%20somehow%20i%20don't%20see%20the%20decorator%20getting%20skipped.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20you%20please%20advise%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3ESai%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2994819%22%20slang%3D%22en-US%22%3ERe%3A%20Decorator%20skipping%20not%20working%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2994819%22%20slang%3D%22en-US%22%3Ecan%20you%20please%20help%20me%20getting%20this%20decorator%20skipper%20fixed.%3CBR%20%2F%3Ewhen%20i%20match%20the%20command%20line%20task%20from%20the%20decorator%20pipeline%20to%20the%20one%20in%20pipeline.yaml%20file.%20it%20is%20skipping%2C%20once%20i%20remove%20the%20command%20it%20is%20not%20working.%3CBR%20%2F%3E%3CBR%20%2F%3EPlease%20find%20the%20decorator.yaml%20and%20pipeline.yaml%20below.%3CBR%20%2F%3Esteps%3A%3CBR%20%2F%3E-%20%24%7B%7B%20if%20ne(variables%5B'skipInjecting'%5D%2C%20'true')%20%7D%7D%3A%3CBR%20%2F%3E-%20script%3A%20echo%20%22%24(variables%5B'skipInjecting'%5D)%22%3CBR%20%2F%3E-%20bash%3A%20echo%20This%20is%20the%20Bash%20task%3CBR%20%2F%3E-%20task%3A%20PowerShell%402%3CBR%20%2F%3Einputs%3A%3CBR%20%2F%3EtargetType%3A%20inline%3CBR%20%2F%3Escript%3A%20echo%20%22%24(variables%5B'skipInjecting'%5D)%22%3CBR%20%2F%3E-%20task%3A%20ADOSecurityScanner%401%3CBR%20%2F%3Einputs%3A%3CBR%20%2F%3EOrgName%3A%20'%24(System.CollectionUri)'%3CBR%20%2F%3EProjectNames%3A%20'%24(System.TeamProject)'%3CBR%20%2F%3EScanFilter%3A%20'All'%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Etrigger%3A%3CBR%20%2F%3E-%20master%3CBR%20%2F%3E%3CBR%20%2F%3Epool%3A%3CBR%20%2F%3EvmImage%3A%20ubuntu-latest%3CBR%20%2F%3E%3CBR%20%2F%3Evariables%3A%3CBR%20%2F%3EskipInjecting%3A%20'true'%3CBR%20%2F%3E%3CBR%20%2F%3Esteps%3A%3CBR%20%2F%3E-%20script%3A%20echo%20This%20is%20the%20only%20step.%20No%20decorator%20is%20added.%3CBR%20%2F%3E%3CBR%20%2F%3E-%20script%3A%20echo%20Hello%2C%20world!%3CBR%20%2F%3EdisplayName%3A%20'Run%20a%20one-line%20script'%3CBR%20%2F%3E%3CBR%20%2F%3E-%20script%3A%20%7C%3CBR%20%2F%3Eecho%20Add%20other%20tasks%20to%20build%2C%20test%2C%20and%20deploy%20your%20project.%3CBR%20%2F%3Eecho%20See%20%3CA%20href%3D%22https%3A%2F%2Faka.ms%2Fyaml%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Faka.ms%2Fyaml%3C%2FA%3E%3CBR%20%2F%3EdisplayName%3A%20'Run%20a%20multi-line%20script'%3CBR%20%2F%3E%3CBR%20%2F%3E-%20task%3A%20CmdLine%402%3CBR%20%2F%3Etask%3A%20PowerShell%402%3CBR%20%2F%3Einputs%3A%3CBR%20%2F%3EtargetType%3A%20inline%3CBR%20%2F%3Escript%3A%20echo%20%22%24(variables%5B'skipInjecting'%5D)%22%3CBR%20%2F%3E%3CBR%20%2F%3Ecan%20you%20please%20help%20in%20getting%20this%20fixed.%3C%2FLINGO-BODY%3E
New Contributor

I developed a decorator based on Microsoft documentation. The injecting part is working as expected and the skipping part is not working as expected. i tried it multiple times, in different ways according  to documentation provided by Microsoft and the injected decorator is not getting skipped.

 

Below is the method i followed from documentation. There is not enough documentation on capturing the decorator logs can you please advise.

 

steps:

- ${{ if ne(variables['skipInjecting'], 'true') }}:

  - script: echo Injected the decorator

 

and in the pipeline i added the variables

 

variables:

  skipInjecting: true

    steps:

     - script: echo This is the only step. No decorator is added.

 

I used the same syntax from the Microsoft Documentation.  somehow i don't see the decorator getting skipped.

 

Can you please advise?

 

Thanks

Sai

1 Reply
can you please help me getting this decorator skipper fixed.
when i match the command line task from the decorator pipeline to the one in pipeline.yaml file. it is skipping, once i remove the command it is not working.

Please find the decorator.yaml and pipeline.yaml below.
steps:
- ${{ if ne(variables['skipInjecting'], 'true') }}:
- script: echo "$(variables['skipInjecting'])"
- bash: echo This is the Bash task
- task: PowerShell@2
inputs:
targetType: inline
script: echo "$(variables['skipInjecting'])"
- task: ADOSecurityScanner@1
inputs:
OrgName: '$(System.CollectionUri)'
ProjectNames: '$(System.TeamProject)'
ScanFilter: 'All'


trigger:
- master

pool:
vmImage: ubuntu-latest

variables:
skipInjecting: 'true'

steps:
- script: echo This is the only step. No decorator is added.

- script: echo Hello, world!
displayName: 'Run a one-line script'

- script: |
echo Add other tasks to build, test, and deploy your project.
echo See https://aka.ms/yaml
displayName: 'Run a multi-line script'

- task: CmdLine@2
task: PowerShell@2
inputs:
targetType: inline
script: echo "$(variables['skipInjecting'])"

can you please help in getting this fixed.