1313# See example YAML call for this script below. Note the use of the variable `$(dn-bot-dnceng-artifact-feeds-rw)`
1414# from the AzureDevOps-Artifact-Feeds-Pats variable group.
1515#
16+ # Any disabledPackageSources entries which start with "darc-int" will be re-enabled as part of this script executing.
17+ #
1618# - task: Bash@3
1719# displayName: Setup Private Feeds Credentials
1820# inputs:
@@ -63,7 +65,7 @@ if [ "$?" != "0" ]; then
6365 ConfigNodeHeader=" <configuration>"
6466 PackageSourcesTemplate=" ${TB} <packageSources>${NL}${TB} </packageSources>"
6567
66- sed -i.bak " s|$ConfigNodeHeader |$ConfigNodeHeader ${NL} $PackageSourcesTemplate |" NuGet.config
68+ sed -i.bak " s|$ConfigNodeHeader |$ConfigNodeHeader ${NL} $PackageSourcesTemplate |" $ConfigFile
6769fi
6870
6971# Ensure there is a <packageSourceCredentials>...</packageSourceCredentials> section.
@@ -74,7 +76,7 @@ if [ "$?" != "0" ]; then
7476 PackageSourcesNodeFooter=" </packageSources>"
7577 PackageSourceCredentialsTemplate=" ${TB} <packageSourceCredentials>${NL}${TB} </packageSourceCredentials>"
7678
77- sed -i.bak " s|$PackageSourcesNodeFooter |$PackageSourcesNodeFooter ${NL} $PackageSourceCredentialsTemplate |" NuGet.config
79+ sed -i.bak " s|$PackageSourcesNodeFooter |$PackageSourcesNodeFooter ${NL} $PackageSourceCredentialsTemplate |" $ConfigFile
7880fi
7981
8082PackageSources=()
@@ -146,4 +148,21 @@ for FeedName in ${PackageSources[@]} ; do
146148
147149 sed -i.bak " s|$PackageSourceCredentialsNodeFooter |$NewCredential ${NL} $PackageSourceCredentialsNodeFooter |" $ConfigFile
148150 fi
149- done
151+ done
152+
153+ # Re-enable any entries in disabledPackageSources where the feed name contains darc-int
154+ grep -i " <disabledPackageSources>" $ConfigFile
155+ if [ " $? " == " 0" ]; then
156+ DisabledDarcIntSources=()
157+ echo " Re-enabling any disabled \" darc-int\" package sources in $ConfigFile "
158+ DisabledDarcIntSources+=$( grep -oh ' "darc-int-[^"]*" value="true"' $ConfigFile | tr -d ' "' )
159+ for DisabledSourceName in ${DisabledDarcIntSources[@]} ; do
160+ if [[ $DisabledSourceName == darc-int* ]]
161+ then
162+ OldDisableValue=" add key=\" $DisabledSourceName \" value=\" true\" "
163+ NewDisableValue=" add key=\" $DisabledSourceName \" value=\" false\" "
164+ sed -i.bak " s|$OldDisableValue |$NewDisableValue |" $ConfigFile
165+ echo " Neutralized disablePackageSources entry for '$DisabledSourceName '"
166+ fi
167+ done
168+ fi
0 commit comments