Recently my workplace has been transitioning over from CircleCI to Azure Pipelines, and as such we have been migrating all of our CI. While most have been somewhat straight forward, this particular pipeline requires running our linux job inside of a docker image. Here is what was in CircleCI:
build:
docker:
- image: electronuserland/builder:wine-03.18
steps:
- run: apt-get update
- run: apt-get install -y libgnome-keyring-dev icnsutils graphicsmagick xz-utils rpm bsdtar
- run: yarn install
# run tests!
- run: yarn test -- -u
- run: yarn test -- --maxWorkers 2
# Build the React app and the Electron app
- run:
name: yarn run electron-pack
VERSION=$(node -p "var ipVer = require('./package.json').version; \
var semVer = require('semver'); \
var sprintf = require('sprintf-js').sprintf; \
sprintf('%s.%s.%s%s', semVer.major(ipVer), semVer.minor(ipVer), semVer.patch(ipVer), '$ReleaseVAR');")
yarn version --no-git-tag-version --new-version VERSION
yarn run electron-pack
# Move the packages into a separate directory
- run: mkdir dist/packages
- run: mv dist/*.exe dist/packages
- run: mv dist/*.AppImage dist/packages
- run: mv dist/*.deb dist/packages
- run: mv dist/*.rpm dist/packages
And here is what it currently looks like in Azure Pipelines:
jobs:
- job: Linux
pool:
name: 'Hosted Ubuntu 1604'
vmImage: 'ubuntu-16.04'
container:
image: electronuserland/builder:wine-03.18
options: --privileged
steps:
- task: NodeTool@0
inputs:
versionSpec: '8.x'
displayName: 'Install Node.js'
#- script: apt-get update
# displayName: apt-get update
#- script: sudo apt-get install -y libgnome-keyring-dev icnsutils graphicsmagick xz-utils rpm bsdtar
# displayName: apt-get install
#- script: sudo apt-get -f install
#- script: sudo apt-get install -y wine
- task: Npm@1
inputs:
command: 'install'
- script: yarn test -- -u --coverage
displayName: yarn -u
- script: yarn test -- --maxWorkers 2 --coverage
displayName: yarn maxWorkers 2
- script: |
VER=$(node -p "var ipVer = require('./package.json').version; \
var semVer = require('semver'); \
var sprintf = require('sprintf-js').sprintf; \
sprintf('%s.%s.%s%s', semVer.major(ipVer), semVer.minor(ipVer), semVer.patch(ipVer), '$(Build.BuildNumber)');")
yarn version --no-git-tag-version --new-version $(VER)
yarn run electron-pack
Any attempt to run the script without the 'apt-get' lines fails during the last script, yielding a Error: Exit code: ENOENT. spawn icns2png ENOENT error. Trying to run those lines, gives a
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?]
error, and attempting to run 'sudo apt-get' gives a
/__w/_temp/ac8e299a-ba1c-4e18-8baa-93d3f4a189e3.sh: line 1: sudo: command not found
error. But to install sudo I need to be able to run 'apt-get install sudo -y'
This causes a circular cycle of not being able to proceed. How can I get the apt-get commands to run inside the Azure Pipelines? I should note that the Mac version of this ran without requiring any modifications or needing the docker image.
How can I get the apt-get commands to run inside the Azure Pipelines?
It seems this is related to the docker images. As we know, Docker images typically do not have sudo
, we are always runs as root
by default. In this case, we could use the command apt-get
directly.
But this image seems runs as non-root, so for root-access things you have to switch into root. In a Dockerfile
, you can simply switch user identities with a USER directive; this generally defaults to running as root:
USER root
To resolve this issue, you may need to custom your docker image based on the image: electronuserland/builder:wine-03.18
.
You could try to check this thread for some more details.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With