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

Missing information about git branch in cypress dashboard runs for BuildKite #777

Closed
pawelgalazka opened this issue Oct 20, 2017 · 23 comments
Labels
CI General issues involving running in a CI provider type: enhancement Requested enhancement of existing feature
Milestone

Comments

@pawelgalazka
Copy link

pawelgalazka commented Oct 20, 2017

Current behavior:

Lack of information about the git branch in Cypress Dashboard runs

screen shot 2017-10-20 at 11 48 37 am

I couldn't find anything about that in the docs, issues and in configuration.

Desired behavior:

See information from what git branch Cypress test runs comes from.

  • Operating System: Linux Debian - 8.8
  • Cypress Version: 1.0.2
  • Browser Version: Electron 53.0.2785.143
  • CI service: Buildkite
@bahmutov
Copy link
Contributor

bahmutov commented Oct 20, 2017 via email

@brian-mann
Copy link
Member

Seeing 113 tests pass with 0 failures makes me happy ;-)

This function is responsible for figuring out the branch:
https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/modes/record.coffee#L25

It uses env vars for a few known CI providers, otherwise it pulls it from git. Not sure why it would not be able to read it off correctly.

@pawelgalazka
Copy link
Author

pawelgalazka commented Oct 20, 2017

Would be great to provide to cypress env name which stores info about the branch.

@brian-mann
Copy link
Member

We could just add buildkite branch to the function

https://buildkite.com/docs/builds/environment-variables

@brian-mann brian-mann self-assigned this Oct 20, 2017
@brian-mann brian-mann added the type: enhancement Requested enhancement of existing feature label Oct 20, 2017
@brian-mann brian-mann added this to the 1.0.3 milestone Oct 20, 2017
@pawelgalazka
Copy link
Author

Also would be great to fill out CI field as for buildkite it just shows unknown

@bahmutov
Copy link
Contributor

I think git cannot determine the branch there, because (I am playing with Buildkite now) it does a trick to check (it is not a branch)

$ git checkout -f FETCH_HEAD
--
  | Note: checking out 'FETCH_HEAD'.
  |  
  | You are in 'detached HEAD' state. You can look around, make experimental
  | changes and commit them, and you can discard any commits you make in this
  | state without impacting any branches by performing another checkout.
  |  
  | If you want to create a new branch to retain commits you create, you may
  | do so (now or later) by using -b with the checkout command again. Example:
  |  
  | git checkout -b <new-branch-name>

@brian-mann
Copy link
Member

@pawelgalazka We setup buildkite on a project here, and the Dashboard captured the CI provider correctly.

Our code had already taken into account Buildkite. Click on the env vars tab on one of your builds to see if Buildkite is exporting the env vars correctly.

As long as it exports BUILDKITE we will pick it up. Code for that is here: https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/util/ci_provider.coffee#L15

@brian-mann
Copy link
Member

Fixed in 1.0.3.

@pawelgalazka
Copy link
Author

Hmm... I'm using 1.0.3 and I still see missing branch info in dashboard.

@bahmutov
Copy link
Contributor

Weird, we do have branch in our Buildkite test runs on production

screen shot 2017-10-31 at 9 34 41 am

Can you check yourself by printing environment variables starting with BUILDKITE using this module to confirm that branch is there? https://github.com/bahmutov/print-env

Otherwise I suggest debugging this yourself to find what is going wrong?

@ArieLevs
Copy link

Hi,

Was this issue resolved?
I'm using Jenkins and Github with Cypress version 3.0.1, and Branch is still blank

screen shot 2018-07-11 at 13 53 39

@jennifer-shehane
Copy link
Member

@ArieLevs Could you open a new issue please? The issue with BuildKite's links were resolved. Each CI service unfortunately requires different code to get these variables working. ☺️

@grrowl
Copy link

grrowl commented Oct 10, 2018

In our case, we're running tests on all branches as buildkite is being fired via webhook on pull_request and on push events. We also run tests on master, which never has an associated PR, so the "Branch:" in cypress dashboard is blank in these cases. It would be great to use BUILDKITE_BRANCH or fall back to it when _PULL_REQUEST_BRANCH is empty. Our environment variables look like this:

In our case we

BUILDKITE_BRANCH="feature/QUAL-165_Add_article_test"
BUILDKITE_PULL_REQUEST="false"
BUILDKITE_PULL_REQUEST_BASE_BRANCH=""
BUILDKITE_PULL_REQUEST_REPO=""

edit: realised we weren't passing all the buildkite envs through to our cypress docker container, but still getting blanks for our master branch

@benmardana
Copy link

benmardana commented Jan 9, 2019

We are exporting all variables but Cypress is failing to resolve the CI provider and branch name. Other variables appear (see screenshot) but not provider or branch :/

Using Cypress v3.1.4

I've read through packages/server/lib/util/ci_provider.js and packages/server/lib/modes/record.coffee but can't seem to see any issues that would cause this. Especially as some variables are successfully detected but not the provider by _detectProviderName().

screen shot 2019-01-09 at 5 53 20 pm

Our buildkite env looks something like this (n.b. not from same branch as above screenshot):

BUILDKITE="true"
BUILDKITE_AGENT_ID="****"
BUILDKITE_AGENT_META_DATA_AWS_AMI_ID="****"
BUILDKITE_AGENT_META_DATA_AWS_INSTANCE_ID="****"
BUILDKITE_AGENT_META_DATA_AWS_INSTANCE_TYPE="****"
BUILDKITE_AGENT_META_DATA_BUILDKITE_AWS_STACK="****"
BUILDKITE_AGENT_META_DATA_DOCKER="****"
BUILDKITE_AGENT_META_DATA_QUEUE="elastic"
BUILDKITE_AGENT_META_DATA_STACK="buildkite"
BUILDKITE_AGENT_NAME="buildkite-i-****"
BUILDKITE_ARTIFACT_PATHS="cypress/videos/*;cypress/screenshots/*;cypress/videos/**/*;cypress/screenshots/**/*"
BUILDKITE_BRANCH="revert-2049"
BUILDKITE_BUILD_CREATOR="John Smith"
BUILDKITE_BUILD_CREATOR_EMAIL="john@good-emails.com.au"
BUILDKITE_BUILD_ID="****"
BUILDKITE_BUILD_NUMBER="****"
BUILDKITE_BUILD_URL="https://buildkite.com/company/company-cypress/builds/5162"
BUILDKITE_COMMAND="ops/run_cypress.sh"
BUILDKITE_COMMIT="****"
BUILDKITE_JOB_ID="****"
BUILDKITE_LABEL=":chrome: Run Cypress Tests %n"
BUILDKITE_MESSAGE="Revert \"SK-3131""
BUILDKITE_ORGANIZATION_SLUG="company"
BUILDKITE_PARALLEL_JOB="0"
BUILDKITE_PARALLEL_JOB_COUNT="2"
BUILDKITE_PIPELINE_DEFAULT_BRANCH="master"
BUILDKITE_PIPELINE_PROVIDER="github"
BUILDKITE_PIPELINE_SLUG="company-cypress"
BUILDKITE_PULL_REQUEST="false"
BUILDKITE_PULL_REQUEST_BASE_BRANCH=""
BUILDKITE_PULL_REQUEST_REPO=""
BUILDKITE_REBUILT_FROM_BUILD_ID=""
BUILDKITE_REBUILT_FROM_BUILD_NUMBER=""
BUILDKITE_REPO="git@github.com:company/company.git"
BUILDKITE_REPO_SSH_HOST="github.com"
BUILDKITE_RETRY_COUNT="0"
BUILDKITE_SCRIPT_PATH="ops/run_cypress.sh"
BUILDKITE_SOURCE="trigger_job"
BUILDKITE_TAG=""
BUILDKITE_TIMEOUT="false"
BUILDKITE_TRIGGERED_FROM_BUILD_ID="****"
BUILDKITE_TRIGGERED_FROM_BUILD_NUMBER="****"
BUILDKITE_TRIGGERED_FROM_BUILD_PIPELINE_SLUG="company"
CI="true"

@jennifer-shehane jennifer-shehane changed the title Missing information about git branch in cypress dashboard runs Missing information about git branch in cypress dashboard runs for BuildKite Jan 9, 2019
@bahmutov
Copy link
Contributor

bahmutov commented Jan 9, 2019

@benyamini Can I ask you to run on BuildKite CI with environment variable DEBUG=cypress:server,commit-info please? This will print a lot more additional messages, and we will see what information we get from provider. These are strings like git commit existing info.

Note: before pasting the relevant part of the log here (we are only interested in the commit and provider information) make sure to remove all sensitive values, like record keys.

@bahmutov bahmutov reopened this Jan 9, 2019
@bahmutov bahmutov assigned bahmutov and unassigned brian-mann Jan 9, 2019
@benmardana
Copy link

benmardana commented Jan 9, 2019

@bahmutov See output from cypress debug below.

Added this env variable: export DEBUG=cypress:server,commit-info


Opening Cypress...
--
  | commit-info commit-info in folder /app +0ms
  | commit-info using Git tool to find branch +0ms
  | commit-info running git command: git rev-parse --abbrev-ref HEAD +0ms
  | commit-info in folder /app +1ms
  | commit-info running git command: git show -s --pretty=%B +14ms
  | commit-info in folder /app +0ms
  | commit-info running git command: git show -s --pretty=%ae +8ms
  | commit-info in folder /app +0ms
  | commit-info running git command: git show -s --pretty=%an +13ms
  | commit-info in folder /app +0ms
  | commit-info running git command: git show -s --pretty=%H +15ms
  | commit-info in folder /app +0ms
  | commit-info running git command: git config --get remote.origin.url +14ms
  | commit-info in folder /app +0ms
  | commit-info git stdout: HEAD +20ms
  | commit-info git stdout: add debug env vars to buildkite
  | +0ms
  | commit-info git stdout: john@company.com +0ms
  | commit-info git stdout: John Smith +0ms
  | commit-info git stdout: **** +0ms
  | commit-info git stdout: git@github.com:company/project.git +0ms
  | commit-info git commit: { 
        branch: null, 
        message: 'add debug env vars to buildkite\n', 
        email: 'john@company.com', 
        author: 'John Smith', 
        sha: '****', 
        remote: 'git@github.com:company/project.git' 
     } +87ms
  | commit-info env commit: { 
        branch: null, 
        message: null, 
        email: null, 
        author: null, 
        sha: null, 
        remote: null 
     } +2ms
  | cypress:server git commit existing info +0ms
  | cypress:server { sha: '****',
  | cypress:server   branch: null,
  | cypress:server   authorName: 'John Smith',
  | cypress:server   authorEmail: 'john@company.com',
  | cypress:server   message: 'add debug env vars to buildkite\n',
  | cypress:server   remoteOrigin: 'git@github.com:company/project.git',
  | cypress:server   defaultBranch: null } +0ms
  | cypress:server commit info from provider environment variables +2ms
  | cypress:server {} +0ms
  | cypress:server combined git and environment variables from provider +1ms
  | cypress:server { sha: '****',
  | cypress:server   branch: null,
  | cypress:server   authorName: 'John Smith',
  | cypress:server   authorEmail: 'john@company.com',
  | cypress:server   message: 'add debug env vars to buildkite\n',
  | cypress:server   remoteOrigin: 'git@github.com:company/project.git',
  | cypress:server   defaultBranch: null } +0ms


@bahmutov
Copy link
Contributor

@benyamini I still do not see how this error could happen, the unit tests report correct info with these environment variables. For now I have added DEBUG printing of a few more variables in #3131 which will allow us to pinpoint the problem a little bit more in the future runs.

@benmardana
Copy link

@bahmutov same here... everything seems to be in the correct place. Thanks for your work on this one. Hopefully something pops out.

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Jan 30, 2019
@tnrich
Copy link
Contributor

tnrich commented Mar 27, 2019

I'm seeing a more extreme version of this when running our tests from within HerokuCI:

image

Branch, Author, Commit, Message and CI are all blank.

What's the recommended way of troubleshooting this? Thanks!

@flotwig
Copy link
Contributor

flotwig commented Mar 27, 2019

@tnrich it doesn't look like we're set up to pull Heroku CI environment variables in: https://on.cypress.io/continuous-integration#Examples

I'm not sure why it's not automatically pulling them from the commit, maybe Heroku CI doesn't build with the .git directory available and so commit-info fails.

We could potentially add Heroku CI environment variables and support pulling the info in that way in ci_provider.js, but I couldn't find much documentation about what environment variables Heroku makes available besides this.

@jennifer-shehane jennifer-shehane removed the stage: needs information Not enough info to reproduce the issue label Jul 11, 2019
@hvuong-sigma
Copy link

@benyamini Were you able to extract the info for branch and ci?

@LiuVII
Copy link

LiuVII commented Aug 13, 2019

we running cypress 3.3.2
from what we tested there are two necessary environment settings that should fill in branch and ci fields for the dashboard:

  1. BUILDKITE=true
  2. BUILDKITE_BRANCH=your-branch-name-here
    both should be available/set in the same environment context where you do cypress run ... (like if you have Dockerfile that you're building inside your CI which you use to run cypress you should set these variables inside the image or container)

@bahmutov
Copy link
Contributor

bahmutov commented Aug 13, 2019

@tnrich Heroku CI does not seem to provide any commit information as environment variables, if you have that information you should set it yourself via COMMIT_INFO_* environment variables https://github.com/cypress-io/commit-info#fallback-environment-variables

For now, I am closing this issue, since BuiltKite env variables should be available I believe.

@jennifer-shehane jennifer-shehane added CI General issues involving running in a CI provider and removed CI: buildkite labels Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI General issues involving running in a CI provider type: enhancement Requested enhancement of existing feature
Projects
None yet
Development

No branches or pull requests