watson / ci-info

Get details about the current Continuous Integration environment
MIT License
319 stars 49 forks source link

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

Closed andrii-lundiak closed 10 months ago

andrii-lundiak commented 1 year ago

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 commented 10 months ago

Might be fixed now I guess. After https://github.com/watson/ci-info/pull/116. Please reopen if the issue still exists.

And Apologies for the delay in response.

andrii-lundiak commented 10 months ago

@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