Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure - CI can't be detected inside Docker image built by Azure pipeline Docker task #108

Closed
andrii-lundiak opened this issue Feb 17, 2023 · 2 comments

Comments

@andrii-lundiak
Copy link

andrii-lundiak commented Feb 17, 2023

Not sure its actual bug or relevant issue, but still. Maybe some I'll get hints...

Here is my test code:

const isCI = require('is-ci')

if (isCI) {
  console.log('A - The code is running on a CI server')
} else {
  console.log('A - NOT a CI server')
}

const ci = require('ci-info')

if (ci.isCI) {
  console.log('B - The name of the CI server is:', ci.name)
} else {
  console.log('B - This program is not running on a CI server')
}

So neither ci-info directly nor is-ci

image

And my Dockerfile has such lines:

FROM node:16.18.1
...
COPY --chown=node:node package.json package-lock.json  /tbd/
RUN npm ci --include=dev --no-fund --quiet
RUN npm run build
...
USER node
EXPOSE 4000
ENTRYPOINT ["./docker/project/docker-entrypoint.sh"]

Meaning actual NPM install is being done OUT of Git repo.

Other Details:

Environment variables

Environment variables example

result of execution commend env:

npm_config_user_agent=npm/8.19.2 node/v16.18.1 linux x64 workspaces/false
NODE_VERSION=16.18.1
HOSTNAME=6b********45
YARN_VERSION=1.22.19
npm_node_execpath=/usr/local/bin/node
npm_config_noproxy=
HOME=/root
npm_package_json=/project/package.json
npm_config_userconfig=/root/.npmrc
npm_config_local_prefix=/project
COLOR=0
npm_config_metrics_registry=https://registry.npmjs.org/
npm_config_prefix=/usr/local
npm_config_cache=/root/.npm
npm_config_node_gyp=/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js
PATH=/project/node_modules/.bin:/node_modules/.bin:/usr/local/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
NODE=/usr/local/bin/node
npm_package_name=my-project
npm_config_include=dev
npm_config_fund=
npm_config_loglevel=warn
npm_lifecycle_script=env
npm_package_version=1.67.1
npm_lifecycle_event=postinstall
npm_config_globalconfig=/usr/local/etc/npmrc
npm_config_init_module=/root/.npm-init.js
PWD=/project
npm_execpath=/usr/local/lib/node_modules/npm/bin/npm-cli.js
npm_config_global_prefix=/usr/local
npm_command=ci
INIT_CWD=/project
EDITOR=vi

Additional context
Add any other context about the problem here.

I assume, because OF Docker container/image scope it's NOT CI per se anymore. But this all stuff is executed on CI and that is strange to grasp.

I realize, that I have to pass UPPER level of env BEFORE Docker container/image. But I 1) not yet sure how to it properly, 2) not sure if it worth doing (I just want to disable HUSKY from CI), 3) not sure if this isn't ONLY my problem. Maybe other people do it better.

Task         : Docker
Description  : Build or push Docker images, login or logout, start or stop containers, or run a Docker command
Version      : 2.214.0
Author       : Microsoft Corporation
Help         : https://aka.ms/azpipes-docker-tsg

Maybe there is some flag for Azure Docker task to traverse information about CI. I don't know yet.

@sibiraj-s
Copy link
Collaborator

Might be fixed now I guess. After #116. Please reopen if the issue still exists.

And Apologies for the delay in response.

@andrii-lundiak
Copy link
Author

@sibiraj-s I do confirm, that as of 06/11 I verified that both packages is-ci and ci-info properly recognize Azure CI.

Here is screenshot from using packages within Cypress v13.3.3 setup because it relies/installs/depends on both packages.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants