Open danobot opened 5 years ago
I'm having the same issue, but with GitLab CI. Version is not getting bumped in package.json. It is reproduced with standard-version@^7.0.0
.
Nevermind it was a bug on our side, due to incorrect .gitignore
Had the exact same issue in a bitbucket pipeline; package.json
was never updated, even though it worked perfectly locally. I have no idea why. If I had to guess, I'd say it's a bitbucket issue.
In the end, I wrote a script to do it. Since standard-release
does set the proper git tags, you can read those and update package.json
appropriately:
// updatePkg.js
const fs = require("fs-extra");
const child_process = require("child_process");
const pkg = require("../package.json");
const main = async () => {
const tag = child_process
.execSync(`git describe --abbrev=0`, { encoding: "utf8" })
.trim();
pkg.version = tag.slice(1);
try {
await fs.writeJson("./package.json", pkg, { spaces: 2 });
} catch (err) {
throw err;
}
console.log(`package.json updated, version ${pkg.version}`);
child_process.execSync(
`git commit -am "chore(package.json): bump version [skip ci]"`
);
console.log("package.json update commited");
child_process.execSync("git push");
console.log("package.json update pushed");
};
main();
And the pipeline:
release: &release
step:
name: Release
script:
- npm i
- npm run release
- git push --follow-tags
- npm run update:pkg
- pipe: atlassian/npm-publish:0.2.5
variables:
NPM_TOKEN: $NPM_TOKEN
Had the same issue with .gitignore
, and to save some time for anyone else having this issue it was that our .gitignore
contained the row build
to ignore the build folder.
Bitbucket pipeline cloned the repo into /opt/atlassian/pipelines/agent/build
. And the whole folder was ignored including the package.json
and package-lock.json
files.
Hope it saves some time if anyone else has the same issue.
And this issue could possibly be closed? It would however be an good idea to have an warning message abut any ignored files.
Nice find @fbergstrm. This burned me too. But why would the changelog modifications not be ignored as well?
EDIT
Okay, found out why. The gitignore check is only made in bump.js; not in changelog.js
This looks like a bug. From my understanding, gitignore rule should be applied to the git repository only?
This is our jenkin path (reproducible in local with this folder structure)
/var/lib/jenkins/workspace/package.json
/var/lib/jenkins/workspace/.git
/var/lib/jenkins/workspace/.gitignore
.gitignore contains
lib
In this environment bump.js
will skip updating package.json
. The dotGit.ignore
evaluates /var/lib/jenkins/workspace/package.json
as should be ignored.
From what I understand, this is not the usual behaviour in git. In usual git environment, gitignore rules is only applied to files and folder located starting from where the .gitignore file is located.
This can be verified via:
git status --ignore
Looks like a duplicate of
https://github.com/conventional-changelog/standard-version/issues/253
I am having trouble using this in Bitbucket pipeline. It is consistently committing the changelog witout committing the package.json and the bumped version number.(Resulting in the same release version each time). I tried:
standard-version
without any flags.git add package.json
inprecommit
andrelease
hook.It works perfectly in local environment, I am not sure what I am missing.
Version: 7.0.0
Release Commit:![image](https://user-images.githubusercontent.com/7984567/63205587-38822400-c0d9-11e9-9cd9-ec1ce4d36d0c.png)
Package.json
Bitbucket PIpeline