Sharath Chandra
Sharath Chandra

Reputation: 704

How to set git credentials in azure devops continuous builds

I am creating a release for my Node.js project. The build is configured on gulp.

As a part of the build steps, I need to:

  1. checkout the master and create a new release branch
  2. Update the version on the release branch
  3. commit and push the release branch

All these steps are configured using gulp as


gulp.task('release', gulpSequence(
    'checkout-release-branch',
    'bump-version',
    'clean:dist',
    'compile-ts',
    'commit-appversion-changes-to-release',
    'push-release-branch'
));


gulp.task('checkout-release-branch', function () {

    const packageJSON = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
    git.checkout('release-' + appVersion, { args: '-b' }, function (err) {
        if (err) throw err;
    });
});

gulp.task('bump-version', function () {
    return gulp.src(['./package.json'])
        .pipe(bump({ version: appVersion }).on('error', log.error))
        .pipe(gulp.dest('./'));
});

gulp.task('commit-appversion-changes-to-release', function () {
    return gulp.src('.')
        .pipe(git.add())
        .pipe(git.commit('[Release] Bumped package version number for release'));
});

gulp.task('push-release-branch', function () {
    git.push('origin', 'release-' + appVersion, { args: " -u" }, function (err) {
        if (err) throw err;
    });
});


The above steps when I am running on Azure DevOps give an error for user credentials not being set. I am not sure under what context the build is running. I have given access create and commit branches for "Project Collection Build Service".

What is the way for set credentials for git when I am using gulp-git in Azure DevOps CI builds?

Upvotes: 0

Views: 876

Answers (1)

Josh Gust
Josh Gust

Reputation: 4445

Have you tried using the OAuth token (yaml or designer)?

enter image description here

Upvotes: 1

Related Questions