Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Enabling CORS for Bamboo Edited

Bamboo version: 7.0.2
OS: RHEL 7.5

I have been attempting to make a separate HTML5 webpage for quick information consumption about the state of deployments (finished, failed, current release, etc) from Bamboo by using the REST API, but for the life of me cannot get anything to come through a request. Getting the information straight from the REST url works like a charm, but when it comes to using that in a fetch() or XmlHttpRequest, it's always blocked; I'm not sure if it's server-side or client-side that has the wrong configuration. 

I've tried the configurations from this infamous topic and the links in it as well: https://community.atlassian.com/t5/Bamboo-questions/How-to-enable-CORS-on-Bamboo/qaq-p/429651 and they haven't helped at all.

Trying to use the third-party CORS filter in the WEB-INF/lib results in a catastrophic failure to start (the information is for JIRA anyway- Bamboo doesn't have a whitelist in the UI?).

The conf/web.xml changes are very much a hit and/or miss for what actually is needed for it to work. In my current version, I just place about everything to see what would have an positive effect on getting the information.

In conf/web.xml:

<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
<init-param>
<param-name>cors.allowed.origins</param-name>
<param-value>http://127.0.0.1:8887</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.methods</param-name>
<param-value>GET, POST, HEAD, OPTIONS, PUT</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.headers</param-name>
<param-value>Accept, Authorization, Origin, Content-Type, X-Requested-With, Cookie, Access-Control-Allow-Headers, Access-Control-Request-Headers, Access-Control-Expose-Headers</param-value>
</init-param>
<init-param>
<param-name>cors.exposed.headers</param-name>
<param-value>Access-Control-Allow-Origin, Access-Control-Allow-Credentials</param-value>
</init-param>
<init-param>
<param-name>cors.support.credentials</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>cors.preflight.maxage</param-name>
<param-value>1800</param-value>
</init-param>
<init-param>
<param-name>cors.support.credentials</param-name>
<param-value>true</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
In main.js:

var
headerInfo = new Headers();
headerInfo.append("Origin", "http://127.0.0.1:8887");
headerInfo.append("Content-Type", "application/json");
headerInfo.append("Authorization", "Basic abcde12345");

var requestOptions = {
method: 'GET',
headers: headerInfo,
redirect: 'follow',
mode: 'cors'
};

fetch("http://localhost:8085/rest/api/latest/deploy/environment/1015809/results?expand=results.result&max-results=1", requestOptions)
.then(response => response.text())
.catch(error => console.log('There was an error!', error))
.then(result => console.log(result));

I've tried this locally and on my existing server before, but still without any luck.

 

Is there a clear configuration guide for a default Bamboo installation that enables server-side CORS correctly so I can utilize the REST API? Or has someone else gotten this to work in the (recent) time with a newer version?

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bamboo

Bamboo 7.2 is here!

I'm happy to announce that Bamboo 7.2 has been released and it’s overflowing with awesome new features. This will be the last major Server release before the launch of Bamboo DC. Bamboo logs We...

553 views 6 7
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you