I am trying to comment out an Azure DevOps pipeline stage in multiple yaml files. I tried using
Find in Files
in Notepad++, but unsuccessful.
I am trying to comment out the following stage.
- stage: "check_code"
jobs:
- job: "check_code"
pool:
vmImage: 'windows-latest'
steps:
- template: check_code.yml@templates
parameters:
projectName: '$(projectName)'
This is what I am trying to acheive.
# - stage: "check_code"
# jobs:
# - job: "check_code"
# pool:
# vmImage: 'windows-latest'
# steps:
# - template: check_code.yml@templates
# parameters:
# projectName: '$(projectName)'
When I use notepad++, I can copy the lines in the Find what search box but unable to copy the commented out multiple lines in Replace with box.
Any suggestion on how can I replace it?
^(?:(- stage: "check_code"\R)|\G(\h*)(?!-stage)(.+\R))
$2# $1$3
. matches newline
Explanation:
^ # beginning of line
(?: # non capture group
( # group 1
- stage: "check_code" # literally
\R # any kind of linebreak
) # end group 1
| # OR
\G # restart from last match position
(\h*) # group 2, 0 or more horizontal spaces
(?!-stage) # negative lookahead, make sure we haven't -stage after
( # group 3
.+ # 1 or more any character
\R # any kind of linebreak
) # end group 3
) # end group
Screenshot (before):
Screenshot (after):