是否可以使用Gitlab API创建CI变量?

时间:2019-11-10 18:56:35

标签: gitlab gitlab-ci gitlab-api

我正在将项目从托管的Gitlab-ce迁移到Gitlab.com,并希望更有效地迁移变量。因此,我尝试使用Gitlab API,但没有执行任何操作。这是我尝试过的方法:

curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/variables" --form "key=NEW_VARIABLE" --form "value=new value"

详细:

*   Trying 35.231.145.151...
* TCP_NODELAY set
* Connected to www.gitlab.com (35.231.145.151) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: OU=Domain Control Validated; OU=PositiveSSL Multi-Domain; CN=gitlab.com
*  start date: Jun 27 00:00:00 2019 GMT
*  expire date: May 11 23:59:59 2020 GMT
*  subjectAltName: host "www.gitlab.com" matched cert's "www.gitlab.com"
*  issuer: C=GB; ST=Greater Manchester; L=Salford; O=Sectigo Limited; CN=Sectigo RSA Domain Validation Secure Server CA
*  SSL certificate verify ok.
> POST /api/v4/projects/<my-project-id>/variables HTTP/1.1
> Host: www.gitlab.com
> User-Agent: curl/7.58.0
> Accept: */*
> PRIVATE-TOKEN: <my-token>
> Content-Length: 253
> Content-Type: multipart/form-data; boundary=------------------------e33f3d40ebb8591f
> 
< HTTP/1.1 308 Permanent Redirect
< Content-length: 0
< Location: https://gitlab.com/api/v4/projects/15160496/variables
< Connection: close
< 
* Closing connection 0
* TLSv1.2 (OUT), TLS alert, Client hello (1):

有没有可能?如果可能,我在做什么错了?

0 个答案:

没有答案