17
17
# displayName: Setup Private Feeds Credentials
18
18
# inputs:
19
19
# filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.sh
20
- # arguments: $BUILD_SOURCESDIRECTORY /NuGet.config $Token
20
+ # arguments: $(Build.SourcesDirectory) /NuGet.config $Token
21
21
# condition: ne(variables['Agent.OS'], 'Windows_NT')
22
22
# env:
23
23
# Token: $(dn-bot-dnceng-artifact-feeds-rw)
@@ -42,7 +42,12 @@ scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
42
42
. " $scriptroot /tools.sh"
43
43
44
44
if [ ! -f " $ConfigFile " ]; then
45
- echo " Couldn't find the file NuGet config file: $ConfigFile "
45
+ Write-PipelineTelemetryError -Category ' Build' " Error: Eng/common/SetupNugetSources.sh returned a non-zero exit code. Couldn't find the NuGet config file: $ConfigFile "
46
+ ExitWithExitCode 1
47
+ fi
48
+
49
+ if [ -z " $CredToken " ]; then
50
+ Write-PipelineTelemetryError -category ' Build' " Error: Eng/common/SetupNugetSources.sh returned a non-zero exit code. Please supply a valid PAT"
46
51
ExitWithExitCode 1
47
52
fi
48
53
@@ -52,7 +57,7 @@ if [[ `uname -s` == "Darwin" ]]; then
52
57
fi
53
58
54
59
# Ensure there is a <packageSources>...</packageSources> section.
55
- grep -i " <packageSources>" $ConfigFile
60
+ grep -i " <packageSources>" $ConfigFile
56
61
if [ " $? " != " 0" ]; then
57
62
echo " Adding <packageSources>...</packageSources> section."
58
63
ConfigNodeHeader=" <configuration>"
@@ -62,7 +67,7 @@ if [ "$?" != "0" ]; then
62
67
fi
63
68
64
69
# Ensure there is a <packageSourceCredentials>...</packageSourceCredentials> section.
65
- grep -i " <packageSourceCredentials>" $ConfigFile
70
+ grep -i " <packageSourceCredentials>" $ConfigFile
66
71
if [ " $? " != " 0" ]; then
67
72
echo " Adding <packageSourceCredentials>...</packageSourceCredentials> section."
68
73
@@ -72,37 +77,64 @@ if [ "$?" != "0" ]; then
72
77
sed -i.bak " s|$PackageSourcesNodeFooter |$PackageSourcesNodeFooter ${NL} $PackageSourceCredentialsTemplate |" NuGet.config
73
78
fi
74
79
75
- # Ensure dotnet3-internal and dotnet3-internal-transport is in the packageSources
76
- grep -i " <add key=\" dotnet3-internal\" >" $ConfigFile
77
- if [ " $? " != " 0" ]; then
78
- echo " Adding dotnet3-internal to the packageSources."
80
+ PackageSources=()
79
81
80
- PackageSourcesNodeFooter=" </packageSources>"
81
- PackageSourceTemplate=" ${TB} <add key=\" dotnet3-internal\" value=\" https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3-internal/nuget/v2\" />"
82
+ # Ensure dotnet3-internal and dotnet3-internal-transport are in the packageSources if the public dotnet3 feeds are present
83
+ grep -i " <add key=\" dotnet3\" " $ConfigFile
84
+
85
+ if [ " $? " == " 0" ]; then
86
+ grep -i " <add key=\" dotnet3-internal\" >" $ConfigFile
87
+ if [ " $? " != " 0" ]; then
88
+ echo " Adding dotnet3-internal to the packageSources."
89
+ PackageSourcesNodeFooter=" </packageSources>"
90
+ PackageSourceTemplate=" ${TB} <add key=\" dotnet3-internal\" value=\" https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3-internal/nuget/v2\" />"
91
+
92
+ sed -i.bak " s|$PackageSourcesNodeFooter |$PackageSourceTemplate ${NL} $PackageSourcesNodeFooter |" $ConfigFile
93
+ fi
94
+ PackageSources+=(' dotnet3-internal' )
95
+
96
+ grep -i " <add key=\" dotnet3-internal-transport\" " $ConfigFile
97
+ if [ " $? " != " 0" ]; then
98
+ echo " Adding dotnet3-internal-transport to the packageSources."
99
+ PackageSourcesNodeFooter=" </packageSources>"
100
+ PackageSourceTemplate=" ${TB} <add key=\" dotnet3-internal-transport\" value=\" https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3-internal-transport/nuget/v2\" />"
82
101
83
- sed -i.bak " s|$PackageSourcesNodeFooter |$PackageSourceTemplate ${NL} $PackageSourcesNodeFooter |" NuGet.config
102
+ sed -i.bak " s|$PackageSourcesNodeFooter |$PackageSourceTemplate ${NL} $PackageSourcesNodeFooter |" $ConfigFile
103
+ fi
104
+ PackageSources+=(' dotnet3-internal-transport' )
84
105
fi
85
106
86
- # Ensure dotnet3-internal and dotnet3-internal-transport is in the packageSources
87
- grep -i " <add key=\" dotnet3-internal-transport\" >" $ConfigFile
88
- if [ " $? " != " 0" ]; then
89
- echo " Adding dotnet3-internal-transport to the packageSources."
107
+ # Ensure dotnet3.1-internal and dotnet3.1-internal-transport are in the packageSources if the public dotnet3.1 feeds are present
108
+ grep -i " <add key=\" dotnet3.1\" " $ConfigFile
109
+ if [ " $? " == " 0" ]; then
110
+ grep -i " <add key=\" dotnet3.1-internal\" " $ConfigFile
111
+ if [ " $? " != " 0" ]; then
112
+ echo " Adding dotnet3.1-internal to the packageSources."
113
+ PackageSourcesNodeFooter=" </packageSources>"
114
+ PackageSourceTemplate=" ${TB} <add key=\" dotnet3.1-internal\" value=\" https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal/nuget/v2\" />"
90
115
91
- PackageSourcesNodeFooter=" </packageSources>"
92
- PackageSourceTemplate=" ${TB} <add key=\" dotnet3-internal-transport\" value=\" https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3-internal-transport/nuget/v2\" />"
116
+ sed -i.bak " s|$PackageSourcesNodeFooter |$PackageSourceTemplate ${NL} $PackageSourcesNodeFooter |" $ConfigFile
117
+ fi
118
+ PackageSources+=(' dotnet3.1-internal' )
93
119
94
- sed -i.bak " s|$PackageSourcesNodeFooter |$PackageSourceTemplate ${NL} $PackageSourcesNodeFooter |" NuGet.config
120
+ grep -i " <add key=\" dotnet3.1-internal-transport\" >" $ConfigFile
121
+ if [ " $? " != " 0" ]; then
122
+ echo " Adding dotnet3.1-internal-transport to the packageSources."
123
+ PackageSourcesNodeFooter=" </packageSources>"
124
+ PackageSourceTemplate=" ${TB} <add key=\" dotnet3.1-internal-transport\" value=\" https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal-transport/nuget/v2\" />"
125
+
126
+ sed -i.bak " s|$PackageSourcesNodeFooter |$PackageSourceTemplate ${NL} $PackageSourcesNodeFooter |" $ConfigFile
127
+ fi
128
+ PackageSources+=(' dotnet3.1-internal-transport' )
95
129
fi
96
130
97
131
# I want things split line by line
98
132
PrevIFS=$IFS
99
133
IFS=$' \n '
100
- PackageSources=$( grep -oh ' "darc-int-[^"]*"' $ConfigFile | tr -d ' "' )
134
+ PackageSources+=" $IFS "
135
+ PackageSources+=$( grep -oh ' "darc-int-[^"]*"' $ConfigFile | tr -d ' "' )
101
136
IFS=$PrevIFS
102
137
103
- PackageSources+=(' dotnet3-internal' )
104
- PackageSources+=(' dotnet3-internal-transport' )
105
-
106
138
for FeedName in ${PackageSources[@]} ; do
107
139
# Check if there is no existing credential for this FeedName
108
140
grep -i " <$FeedName >" $ConfigFile
@@ -112,6 +144,6 @@ for FeedName in ${PackageSources[@]} ; do
112
144
PackageSourceCredentialsNodeFooter=" </packageSourceCredentials>"
113
145
NewCredential=" ${TB}${TB} <$FeedName >${NL} <add key=\" Username\" value=\" dn-bot\" />${NL} <add key=\" ClearTextPassword\" value=\" $CredToken \" />${NL} </$FeedName >"
114
146
115
- sed -i.bak " s|$PackageSourceCredentialsNodeFooter |$NewCredential ${NL} $PackageSourceCredentialsNodeFooter |" NuGet.config
147
+ sed -i.bak " s|$PackageSourceCredentialsNodeFooter |$NewCredential ${NL} $PackageSourceCredentialsNodeFooter |" $ConfigFile
116
148
fi
117
- done
149
+ done
0 commit comments