@@ -11,8 +11,9 @@ The full example template can be found [here](https://github.com/coder/coder/tre
11
11
12
12
- A JFrog Artifactory instance
13
13
- An admin-level access token for Artifactory
14
- - 1:1 mapping of users in Coder to users in Artifactory by email address
15
- - An npm repository in Artifactory named "npm"
14
+ - 1:1 mapping of users in Coder to users in Artifactory by email address and username
15
+ - Repositories configured in Artifactory for each package manager you want to use
16
+
16
17
17
18
<blockquote class =" info " >
18
19
The admin-level access token is used to provision user tokens and is never exposed to
@@ -40,7 +41,7 @@ terraform {
40
41
}
41
42
artifactory = {
42
43
source = "registry.terraform.io/jfrog/artifactory"
43
- version = "6.22.3 "
44
+ version = "~> 8.4.0 "
44
45
}
45
46
}
46
47
}
@@ -57,15 +58,15 @@ variable "artifactory_access_token" {
57
58
58
59
# Configure the Artifactory provider
59
60
provider "artifactory" {
60
- url = "${var.jfrog_url}/artifactory"
61
+ url = "https:// ${var.jfrog_url}/artifactory"
61
62
access_token = "${var.artifactory_access_token}"
62
63
}
63
64
```
64
65
65
- When pushing the template, you can pass in the variables using the ` -V ` flag:
66
+ When pushing the template, you can pass in the variables using the ` --var ` flag:
66
67
67
68
``` sh
68
- coder templates push --var ' jfrog_url=https:// YYY.jfrog.io' --var ' artifactory_access_token=XXX'
69
+ coder templates push --var ' jfrog_url=YYY.jfrog.io' --var ' artifactory_access_token=XXX'
69
70
```
70
71
71
72
## Installing JFrog CLI
@@ -107,9 +108,27 @@ resource "coder_agent" "main" {
107
108
export CI=true
108
109
109
110
jf c rm 0 || true
110
- echo ${artifactory_access_token.me.access_token} | \
111
- jf c add --access-token-stdin --url ${var.jfrog_url} 0
111
+ echo ${artifactory_scoped_token.me.access_token} | \
112
+ jf c add --access-token-stdin --url https://${var.jfrog_url} 0
113
+
114
+ # Configure the `npm` CLI to use the Artifactory "npm" registry.
115
+ cat << EOF > ~/.npmrc
116
+ email = ${data.coder_workspace.me.owner_email}
117
+ registry = https://${var.jfrog_url}/artifactory/api/npm/${local.artifactory_registry_keys["npm"]}
118
+ EOF
119
+ jf rt curl /api/npm/auth >> .npmrc
120
+
121
+ mkdir -p ~/.pip
122
+ cat << EOF > ~/.pip/pip.conf
123
+ [global]
124
+ index-url = https://${data.coder_workspace.me.owner}:${artifactory_scoped_token.me.access_token}@${var.jfrog_url}/artifactory/api/pypi/${local.artifactory_registry_keys["pypi"]}/simple
125
+ EOF
126
+
112
127
EOT
128
+ # Set GOPROXY to use the Artifactory "go" registry.
129
+ env = {
130
+ GOPROXY : "https://${data.coder_workspace.me.owner}:${artifactory_scoped_token.me.access_token}@${var.jfrog_url}/artifactory/api/go/${local.artifactory_registry_keys["go"]}"
131
+ }
113
132
}
114
133
```
115
134
@@ -125,7 +144,7 @@ Distribution URL: https://cdr.jfrog.io/distribution/
125
144
Xray URL: https://cdr.jfrog.io/xray/
126
145
Mission Control URL: https://cdr.jfrog.io/mc/
127
146
Pipelines URL: https://cdr.jfrog.io/pipelines/
128
- User: ammar@....com
147
+ User: ammar
129
148
Access token: ...
130
149
Default: true
131
150
```
@@ -151,11 +170,11 @@ Note that this method will only work if your developers use code-server.
151
170
Add the following line to your ` startup_script ` to configure ` npm ` to use
152
171
Artifactory:
153
172
154
- ``` sh
173
+ ``` shell
155
174
# Configure the `npm` CLI to use the Artifactory "npm" registry.
156
175
cat << EOF > ~/.npmrc
157
176
email = ${data.coder_workspace.me.owner_email}
158
- registry= ${var.jfrog_url} /artifactory/api/npm/npm/
177
+ registry = https:// ${var.jfrog_url} /artifactory/api/npm/npm/
159
178
EOF
160
179
jf rt curl /api/npm/auth >> .npmrc
161
180
` ` `
@@ -165,8 +184,33 @@ use Artifactory as the package registry. You can verify that `npm` is configured
165
184
correctly by running ` npm install --loglevel=http react` and checking that
166
185
npm is only hitting your Artifactory URL.
167
186
168
- You can apply the same concepts to Docker, Go, Maven, and other package managers
169
- supported by Artifactory.
187
+ # # Configuring pip
188
+
189
+ Add the following lines to your ` startup_script` to configure ` pip` to use
190
+ Artifactory:
191
+
192
+ ` ` ` shell
193
+ mkdir -p ~/.pip
194
+ cat << EOF > ~/.pip/pip.conf
195
+ [global]
196
+ index-url = https://${data.coder_workspace.me.owner} :${artifactory_scoped_token.me.access_token} @${var.jfrog_url} /artifactory/api/pypi/pypi/simple
197
+ EOF
198
+ ` ` `
199
+
200
+ Now, your developers can run ` pip install` and transparently use Artifactory as the package registry. You can verify that ` pip` is configured correctly by running ` pip install --verbose requests` and checking that pip is only hitting your Artifactory URL.
201
+
202
+ # # Configuring Go
203
+
204
+ Add the following environment variable to your ` coder_agent` block to configure ` go` to use Artifactory:
205
+
206
+ ` ` ` hcl
207
+ env = {
208
+ GOPROXY : "https://${data.coder_workspace.me.owner} :${artifactory_scoped_token.me.access_token} @${var.jfrog_url} /artifactory/api/go/go"
209
+ }
210
+ ` ` `
211
+
212
+ You can apply the same concepts to Docker, Maven, and other package managers
213
+ supported by Artifactory. See the [JFrog documentation](https://jfrog.com/help/r/jfrog-artifactory-documentation/package-management) for more information.
170
214
171
215
# # More reading
172
216
0 commit comments