Programmatically download latest version

Answered

Hey all,

 

Im trying to create a script to download the latest version of Intellij and do some setup to make onboarding a bit easier. However I have yet to figure out how to fetch the latest version using command line tools. The only way I have figured out how to this is using phantomJs to render the download page to get the link (using curl returns an empty href so some javascript is responsible for populating the url).

Anyway using phantomJs to get the latest link is a bit of a hack. Is there currently any better way to do this?

10 comments
Comment actions Permalink

You can try parsing https://www.jetbrains.com/updates/updates.xml for IDEA_Release channel to get the latest version string, then construct the download link for your platform once you know the latest release version number:

https://download.jetbrains.com/idea/ideaIU-<VERSION>.exe
https://download.jetbrains.com/idea/ideaIU-<VERSION>.tar.gz
https://download.jetbrains.com/idea/ideaIU-<VERSION>.dmg
https://download.jetbrains.com/idea/ideaIU-<VERSION>-custom-jdk-bundled.dmg
2
Comment actions Permalink

Ahh!! That xml file is exactly what I was looking for!

 

Thank you!

0
Comment actions Permalink

Serge, 

Just ran into an issue with the latest critical patch where the download link is not the version number but has an 'b' appended onto the end. Is this a bug with updates.xml or how should our code handle this one off situation?

 

Thanks in advance.

0
Comment actions Permalink

Hi Brian,

actually updates.xml file is designed to be used by our IDEs while performing 'Check for Updates' action. 'version' attribute is used just for presentation, its value is shown in the 'Platform and Plugin Updates' dialog. So it isn't guarantied that this value directly corresponds to the download URLs. 2016.1.2b was a hotfix update and we didn't want to change version name for it. For now you can either add an exception for 2016.1.2 or wait for 2016.1.3 which will be released very soon.

Unfortunately currently there is no reliable way to get the latest version of the IDE programmatically. The URLs provided by Serge aren't quite correct, we started bundling our custom JDK by default with Mac OS X distribution, so there are no '-custom-jdk-bundled.dmg' artifact anymore. Though we plan to fix this problem by providing a reliable way to get download URLs for different versions.

0
Comment actions Permalink

Thanks Nikolay!

0
Comment actions Permalink

I'd also like to prgrammatically determine the latest version of IDEA, but the linked updates.xml does not seem to contain updates for IDEA anymore. Is that somewhere else now?

0
Comment actions Permalink

It does:

<channel id="IDEA_Release" name="IntelliJ IDEA Release" status="release" url="https://www.jetbrains.com/idea/download" feedback="https://youtrack.jetbrains.com" majorVersion="2018" licensing="release">
<build number="181.5540" version="2018.1.6" releaseDate="20180327" fullNumber="181.5540.7">
 
 
https://download.jetbrains.com/product?code=IIU&latest&distribution=windows will download the latest IntelliJ IDEA Ultimate for Windows.
0
Comment actions Permalink

oh indeed - why is the order so incredibly random though?

To figure out the latest version of IDEA I apparently have to fetch all versions and then compare them to find the greatest one. oof.

EDIT: This looks a lot better: https://data.services.jetbrains.com/products/releases?code=IIC

0
Comment actions Permalink

Just for future reference. This is the script I use to get me the latest version and return the file to download.

 

   local extension=".tar.gz"
   if [ $(uname) = Darwin ]; then
      extension=".dmg"
   fi
   #To get the latest version we scan through the updates.xml to find the current release version.
   local builds=$(curl -s https://www.jetbrains.com/updates/updates.xml |\
                  xmllint --xpath "//product[@name='IntelliJ IDEA']/channel[@id='IDEA_Release']" - )
   local latestNumber=$(echo $builds | xmllint --xpath "//build/@number" - |\
                        sed 's/number=\"\([[:digit:]]*\.[[:digit:]]*\)\"/\1/g' | tr " " "\n" | sort -bnr | head -1)
   local latestVersion=$(echo $builds | xmllint --xpath "string(//build[@number=$latestNumber]/@version)" -)
   file="ideaIU-$latestVersion$extension"

This at has been working for me for the past few years. Hopefully it can help someone else.

0
Comment actions Permalink

I use a curl one-liner to update PhpStorm on Ubuntu ;)

sudo curl -L "https://download.jetbrains.com/product?code=PS&latest&distribution=linux" | sudo tar xvz -C /opt/phpstorm --strip 1 && /opt/phpstorm/bin/phpstorm.sh

 

2

Please sign in to leave a comment.