简体   繁体   中英

Get latest git tag using Bamboo

I am trying to display the version of our frontend in the footer of our website. I do this using gulp , which uses simple-git .

Check out this snippet:

var git = require('simple-git')();

[...]

return git.tags(function(err, tags) {
    GIT_TAG = tags.latest;
    return gulp.src(path.join(conf.paths.src, '/*.html'))
               .pipe($.replace('<!-- replaceWith:version -->', 'Frontend v' + GIT_TAG))
               [... some more stuff ...]
});

This seems to work perfectly in my development environment: it gets all the tags and returns the latest tag (2.6.5 for example). However, whenever Bamboo checks out the repository, it gives me an empty array and thus, tags.latest returns nothing.

I have tried setting Bamboo to checkout the whole repository instead of the specific branch, but the same thing happens.

Any ideas? If you need more information, I'm happy to give it!

I haven't found any way to do this using conventional methods, but I have created an SSH Task which simply cd s to the directory and runs git fetch --tags .

Now it works, albeit using a workaround.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM