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

Git branch detection on Jenkins default is wrong (I think) #35

Open
samhatoum opened this issue Jul 5, 2018 · 1 comment
Open

Git branch detection on Jenkins default is wrong (I think) #35

samhatoum opened this issue Jul 5, 2018 · 1 comment

Comments

@samhatoum
Copy link

result = this._env.ghprbSourceBranch;

Looking at the line above, it seems that Percy is resorting to the PR builder plugin branch, however on master builds on Jenkins, the branch becomes HEAD.

I've found GIT_BRANCH to work better, however, that has an issue that it reports origin/master and Percy uses master for baseline snapshots. I couldn't find anywhere to change the baseline branch so I ended up writing this script:

#!/usr/bin/env node
const cli = require('@percy-io/percy-storybook/lib/cli');

process.env.PERCY_BRANCH = process.env.GIT_BRANCH === 'origin/master' ? 'master' : process.env.GIT_BRANCH;
process.env.PERCY_TOKEN = '***';
process.env.PERCY_PROJECT = '***';

cli.run([
  '--build_dir=storybook-content',
  '--widths = 320, 1280'
]).then(() => {
  process.on('exit', () => process.exit(0));
})
.catch(err => {
  console.log('Error: ', err); // eslint-disable-line no-console
  process.on('exit', () => process.exit(1));
});

which I now use to run from NPM. Works for now, but would be awesome if Percy did the smart work.

@juanse417
Copy link

I have the same issue.

Ended up setting PERCY_BRANCH env variable directly on Jenkinsfile when building on master.

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