Use rest api with jquery to run a deploy?



I am looking for enough information on how to create a web page to run a deploy that is scheduled.  I was able to cobble together something that shows the projectId, environmentId, and versionId list (release numbers), and even a calendar to let users pick a date and time, but I am having trouble actually submitting a form that will do something with the information.  I tried $.ajax for example:


First off, authentication is a mystery.
However, it would be best if it used an auth token.  All I see out there is how to create tokens for Jira or Confluence, but nothing for Bamboo.  The steps do not work.        
I think as long as I am logged in to bamboo, no other authentication, and I am guessing if a user were to us this, they would need to have deploy permission to the project.  Yes, yes, why not just use Bamboo (sigh).  This has to do with wanting to use some product called servicenow, so that product will need to run "Something" to do the work for the user.
I still do not know what rest api call is used to include a scheduled time.  I tried to simply run a deploy. Note I tried jsonp to deal with cors, but if you have the magic to get this working, I would love to hear it (application link?  what do you fill in if you have to set that up and where/how do you get the info to setup an application link?:  
     var url = "";
             url += "?environmentId=" + $('#environment').val();
             url += "&versionId=" + $('#release').val();

                        type: 'POST',
                        url: url,
                        data: "",
                        dataType: 'jsonp',
                        async: 'false',
                        success: function() {
                        error: function() { alert("failed!"); }
Whatever I do it will either run and show no error (no alert box pops up), but it will not run deploy, or it will throw:
XMLHttpRequest cannot load Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '' is therefore not allowed access. The response had HTTP status code 401.

I see there is a whitelist option in Bamboo, but it does not let me do anything with it and it does not seem to be REST API related (maybe just for java or plugins).
With jsonp sometimes it says:
Refused to execute script from '…e=basic&callback=jQuery110208378970937783805_1485533032763&_=1485533032764' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.
I am praying somebody can give enough information to do the following:
1. setup token authentication
2. use the token with jquery $.ajax call to run the deployment
3. show me what i need to tack onto the url to also include a schedule for the trigger event.

1 answer

Personally, I would just have the jquery send to a webservice (hosted somewhere, maybe even on the bamboo box itself) and have the webservice perform the magic, and return the information back to the jquery call.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Friday in Jira Service Desk

Are you a Jira Service Desk agent? We want to talk to you!

Are you a whiz at handling tickets and looking at how you can further optimize your workflow with automation? Do you tackle detailed customer support questions while simultaneously getting flooded wi...

142 views 0 8
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you