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

Atlassian Connect add-on development process, baseURL for dev & prod

Frédéric Tardieu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 27, 2016

Hi all,

Until now, I was developping a nodejs JIRA add-on using a locally started JIRA, then promoting the validated code to a heroku production environment. I've been reading the new way to developp locally (https://developer.atlassian.com/static/connect/docs/latest/developing/developing-locally.html), and I am switching to this mode.

But I have a question: a baseURL variable must be set in the add-on descriptior, but how to set it once for development stage and for production stage once, with a different value for development and environment stage? I'd like to set this variable for the two cases, without having to change after when I comit on heroku.

 Currently I have:

  • atlassian-connect.json descriptor file,
  • config.json file

And here are them:

Atlassian-connect.json

{
"key": "deeper",
"name": "Deeper",
"description": "AC add-on.",
"vendor": {
"name": "Tartech Ltd.",
"url": "http://www.tartech.net"
},
"baseUrl": "{{localBaseUrl}}",
"links": {
"self": "{{localBaseUrl}}/atlassian-connect.json",
"homepage": "{{localBaseUrl}}/atlassian-connect.json"
},
"authentication": {
"type": "jwt"
},
"lifecycle": {
// atlassian-connect-express expects this route to be configured to manage the installation handshake
"installed": "/installed"
},
"scopes": [
"READ"
],
"modules": {
"generalPages": [
{
"key": "deeper",
"location": "system.top.navigation.bar",
"name": {
"value": "Deeper"
},
"url": "/deeper",
"conditions": [{
"condition": "user_is_logged_in"
}]
}
]
}
}

config.json

{
"development": {
"port": 3000,
"errorTemplate": true,
"store": {
"adapter": "jugglingdb",
"type": "sqlite3",
"database": "store.db"
},
"hosts": [
"http://admin:admin@localhost:1990/confluence",
"http://admin:admin@localhost:2990/jira"
]
},
"production": {
"port": "$PORT",
"errorTemplate": true,
"localBaseUrl": "https://jira-ft.herokuapp.com",
"store": {
"type": "postgres",
"url": "$DATABASE_URL"
},
"whitelist": [
"*.jira-dev.com",
"*.atlassian.net",
"*.atlassian.com",
"*.jira.com"
]
}
}

Thanks a lot,

Fred

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Ralph Whitbeck
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 27, 2016

Hey Frédéric, 

I'm about to code this exact thing in a boilerplate add-on and I'll use to spin up development quickly.  I've looked at how ACE currently handles it and there's a lot to learn there by reading the code. Here's the plan of attack I'm planning to do based on what ACE is doing:  

What they do is read in the JSON files (using the fs module) for config.json and the descriptor, they're JSON parsed and then searched and replace the {{localBaseUrl}} with the config json value. 

You can see it here https://bitbucket.org/atlassian/atlassian-connect-express/src/be97ee4ec47aaf73a08c7ac64c726deb8cd99e6f/lib/internal/addon-descriptor.js?at=master&fileviewer=file-view-default#addon-descriptor.js-4

Hopefully that helps.

Ralph

Frédéric Tardieu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 27, 2016

Hey Ralp,

Seems to work, but when adding localBaseURL and value to my config.json file in the development section, and trying to upload my add-on to JIRA dev cloud instance, I get the message:

The add-on host returned HTTP response code 404 when we tried to contact it during installation. Please try again later or contact the add-on vendor.

But I see on ngrok log that

GET /atlassian-connect.json 200 OK
GET / 302 Found

Do you have an idea why I get a 404 code in JIRA when ngrok does not show any 404?

Thanks,

Fred

Jake Furler
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 9, 2016

@Frédéric Tardieu if you haven't managed to fix this yet, it looks like JIRA is successfully retrieving your descriptor, but failing to post to your /installed callback. Make sure you've updated the value of the localBaseUrl variable in your config.json to match your current ngrok url. You might have to kill/restart the node app. You can browse to <your-ngrok-url>/atlassian-connect.json to make sure the url in your descriptor matches the url it's being served from.

Jake Furler
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 9, 2016

Ah, I see you solved this over on the google group: https://groups.google.com/forum/#!topic/atlassian-connect-dev/cPMFvK3gN0k

Frédéric Tardieu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 10, 2016

Hi Jake,

Yes right! Thank you anyway for your support!

Cheers,

Fred

TAGS
AUG Leaders

Atlassian Community Events