go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/cli/execruntime/README.md (about)

     1  # Exec Environment Detector
     2  
     3  Usage:
     4  
     5  ```golang
     6  env := ci.Detect()
     7  env.IsAutomatedEnv()
     8  env.Name
     9  ```
    10  
    11  ## CI environments
    12  
    13  * AWS Code Build [Spec](https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html)
    14  * Azure Build Pipeline [Spec](https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops)
    15  * GitLab [Spec](https://docs.gitlab.com/ee/ci/variables/)
    16  * Google Cloud Build [Spec](https://cloud.google.com/cloud-build/docs/configuring-builds/substitute-variable-values#using_default_substitutions)
    17  * CircleCI [Spec](https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables)
    18  * Jenkins [Spec](https://wiki.jenkins.io/display/JENKINS/Building+a+software+project#Buildingasoftwareproject-belowJenkinsSetEnvironmentVariables)
    19  * Travis [Spec](https://docs.travis-ci.com/user/environment-variables/#default-environment-variables)
    20  * GoCD [Spec](https://docs.gocd.org/current/faq/environment_variables.html)
    21  * TeamCity [Spec](https://confluence.jetbrains.com/display/TCD18/Predefined+Build+Parameters#PredefinedBuildParameters-ServerBuildProperties)
    22  
    23  ## Low-level structure
    24  
    25  **list of env vars**
    26  
    27  jenkins:
    28  
    29      Name: "BUILD_ID",
    30      Name: "BUILD_NUMBER",
    31      Name: "BUILD_NUMBER",
    32      Name: "BUILD_URL",
    33      Name: "GIT_COMMIT",
    34      Name: "JENKINS_URL",
    35      Name: "JENKINS_URL",
    36      Name: "JOB_NAME",
    37  
    38  circleci:
    39  
    40      Name: "CIRCLE_BUILD_URL",
    41      Name: "CIRCLE_JOB",
    42      Name: "CIRCLE_PULL_REQUEST",
    43      Name: "CIRCLE_REPOSITORY_URL",
    44      Name: "CIRCLE_SHA1",
    45      Name: "CIRCLE_TAG",
    46      Name: "CIRCLE_USERNAME",
    47  
    48  travis:
    49  
    50      Name: "TRAVIS_BUILD_ID",
    51      Name: "TRAVIS_BUILD_NUMBER",
    52      Name: "TRAVIS_BUILD_WEB_URL",
    53      Name: "TRAVIS_COMMIT",
    54      Name: "TRAVIS_COMMIT_MESSAGE",
    55      Name: "TRAVIS_JOB_ID",
    56      Name: "TRAVIS_JOB_NAME",
    57      Name: "TRAVIS_JOB_WEB_URL",
    58  
    59  gitlab:
    60  
    61      Name: "CI_COMMIT_DESCRIPTION",
    62      Name: "CI_COMMIT_REF_NAME",
    63      Name: "CI_COMMIT_SHA",
    64      Name: "CI_JOB_ID",
    65      Name: "CI_JOB_NAME",
    66      Name: "CI_JOB_URL",
    67      Name: "CI_MERGE_REQUEST_ID",
    68      Name: "CI_MERGE_REQUEST_PROJECT_URL",
    69      Name: "CI_PIPELINE_URL",
    70      Name: "CI_PROJECT_ID",
    71      Name: "CI_PROJECT_NAME",
    72      Name: "CI_PROJECT_URL",
    73      Name: "GITLAB_CI",
    74      Name: "GITLAB_USER_EMAIL",
    75      Name: "GITLAB_USER_ID",
    76      Name: "GITLAB_USER_NAME",
    77  
    78  teamcity
    79  
    80      Name: "TEAMCITY_PROJECT_NAME",
    81      Name: "BUILD_NUMBER",
    82  
    83  **shared names**
    84  
    85  We cannot change the env vars the system is providing, so we have to support the system-specific ones that are listed above. But we should support these in case a user is in another build system and wants to provide build info:
    86  
    87      MONDOO_CI            // true if the CI/CD is used and the value is set to the CI/CD system of this run
    88                           // (eg travis-ci.com, gitlab.com)
    89  
    90      CI_COMMIT_SHA        // i know, it should be checksum... sha is shorter, but not as precise and robust
    91      CI_COMMIT_MESSAGE    // this is just the message, whatever we will use
    92      CI_COMMIT_REF_NAME   // optional, used if specified
    93      CI_COMMIT_URL        // url to the project's PR or the project itself
    94  
    95      CI_PROJECT_NAME      // name of the project in the CI/CD system
    96      CI_PROJECT_ID        // id of this project in the CI/CD system
    97      CI_PROJECT_URL       // url to view this project in the CI/CD system
    98  
    99      CI_BUILD_ID          // internal ID of the target system
   100      CI_BUILD_NAME        // optional, used if specified
   101      CI_BUILD_NUMBER      // 1, 2, ...
   102      CI_BUILD_URL         // url to view the build in the CI/CD system
   103      CI_BUILD_USER_NAME   // user name
   104      CI_BUILD_USER_ID     // user identifier
   105      CI_BUILD_USER_EMAIL  // user email
   106  
   107  ## References
   108  
   109  * https://github.com/watson/ci-info