Is there a way to programmatically create GIT repos in Stash (running Postgres). I need to create 40 odd blank starters in a central model, I have the list of names I want to use.
Definitely.
You can use the Stash REST apis to do this. If you would like to see all the REST endpoints, please have a read through the REST apis or install the REST api browser plugin in Stash.
The REST endpoint you will want to use is as follows:
curl -u user:pass -X POST -H "Accept: application/json" -H "Content-Type: application/json" "http://stash/projects/QA/repos/" -d '{"name": "Repository Name"}'
It means that your request is malformed. Unfortunately it seems that Stash is not providing a good error message in this exact circumstance. If you provide the details of the request you are creating (headers, url, content) then I can look into it and fix your request and also make sure we do better error handling for this case.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The initial post by Seb worked for me as is.
Just don't forget to put /repos/ at the end of your stash project name. eg.
http://yourstashserverhost/projects/yourstashprojectname/repos/
Initially, I only had
http://yourstashserverhost/projects/yourstashprojectname/
so it didn't work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Edit: It now seems to be working with wget but not curl. Clearly this is just a curl issue so I think I will just drop it and use wget. Thanks again for the help.
Thanks, Seb. I actually managed to create a repo by manually creating an http request through a proxy. Here is the request that worked:
POST /rest/api/1.0/projects/[Project Name]/repos HTTP/1.1 Host: [hostname] Connection: keep-alive Authorization: Basic [user:pass (Base64)] Content-Length: 29 Cache-Control: max-age=0 Origin: https://[hostname] User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1 Content-Type: application/json Accept: application/json Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 {"slug":"test","name":"test"}
curl -k -X POST -H "Host: [hostname]" -H "Connection: keep-alive" -H "Authorization: Basic [user:pass(Base64)]" -H "Content-Length: 29" -H "Cache-Control: max-age=0" -H "Origin: https://[hostname]" -H "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1" -H "Content-Type: application/json" -H "Accept: application/json" -H "Accept-Encoding: gzip,deflate,sdch" -H "Accept-Language: en-US,en;q=0.8" -H "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3" --data {"slug":"test", "name":"test"} https://[hostname]/rest/api/1.0/projects/[projectName]/repos/
wget --no-check-certificate --header='Host: [hostname]' --header 'Connection: keep-alive' --header 'Authorization: Basic [user:pass(Base64)]' --header 'Content-Type: application/json' --header 'Accept: application/json' --post-data='{"slug":"test", "name":"test"}' https://[hostname]/rest/api/1.0/projects/[projectName]/repos/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.