How to install a specific version of Google Chrome on GitLab CI?

Viewed 5120

I use CI/CD Gitlab with this script but my Chrome webdriver version is setted in my Maven project (pom.xml):

  before_script:
    ##########################
    # Install  gnupg2        #
    ##########################
    - apt-get install -y gnupg2

    ##################################################
    # Install Latest Google chrome package on system #
    ##################################################
    - curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add
    - echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
    - apt-get -y update
    - apt-get -y install google-chrome-stable

Using the latest version of chrome, I have to change the version of my webdriver in my pom.xml file. how can i force the chrome 80.0.3987.106 version for example?

EDIT:

I try script install chrome from zip file but do not work (/usr/bin/google-chrome is default path use by Chrome webdriver). Pipeline execution stops during/at the end of the unzip command

variables:
    CHROMIUM_URL: https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Linux_x64%2F722276%2Fchrome-linux.zip?alt=media

before_script:
    ##########################
    # Install  gnupg2        #
    ##########################
    - apt-get install -y gnupg2
    
    ##################################################
    # install Chrome 80.0.3987.106
    ##################################################
    - apt-get install zip unzip
    - apt-get install wget
    - apt-get -y install libglib2.0-0
    - apt-get -y install libnss3-dev
    - apt-get -y install libx11-dev
    - wget --output-document chrome-linux64.zip -nv "${CHROMIUM_URL}"
    - unzip -j ./chrome-linux64.zip -d /usr/bin/google-chrome
    - export CHROME_BIN=/usr/bin/google-chrome/chrome

EDIT 2:

I try script install chrome from deb file but do not work.

- apt-get install wget
- wget --output-document chromium-browser.deb -nv http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/chromium-browser_80.0.3987.163-0ubuntu1_amd64.deb
- ls -lrt
- apt install -y ./chromium-browser.deb
1 Answers

It seems you want to install a specific version of Google Chrome using apt-get package manager. You can easily do it in this way:

apt-get -y install google-chrome-stable=VERSION

For example:

apt-get -y install google-chrome-stable=80.0.3987.106


EDIT:

Since Google removes all older versions of Chrome from the PPA and from their download site, the above solution will not be useful.
But it can be suggested to Download .deb file of current version of Google Chrome and upload it on a personal repository. Then you can download and install it in your pipeline whenever you want regardless of Google Chrome's future changes and updates.

Related