How to use gitlab - 10 common examples

To help you get started, we’ve selected a few gitlab examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github piceaTech / node-gitlab-2-github / index.js View on Github external
) {
  console.log('\n\nYou have to enter your GitLab url in the settings.js file.');
  process.exit(1);
}
if (
  !settings.gitlab.token ||
  settings.gitlab.token === '{{gitlab private token}}'
) {
  console.log(
    '\n\nYou have to enter your GitLab private token in the settings.js file.'
  );
  process.exit(1);
}

// Create a GitLab API object
const gitlabApi = new Gitlab({
  url: settings.gitlab.url,
  token: settings.gitlab.token,
});

// Create a GitHub API object
const githubApi = new GitHubApi({
  debug: false,
  baseUrl: settings.github.baseUrl
    ? settings.github.baseUrl
    : 'https://api.github.com',
  timeout: 5000,
  headers: {
    'user-agent': 'node-gitlab-2-github', // GitHub is happy with a unique user agent
    accept: 'application/vnd.github.v3+json',
  },
});
github bufferoverflow / verdaccio-gitlab / src / gitlab.ts View on Github external
authenticate(user: string, password: string, cb: Callback) {
    this.logger.trace(`[gitlab] authenticate called for user: ${user}`);

    // Try to find the user groups in the cache
    const cachedUserGroups = this._getCachedUserGroups(user, password);
    if (cachedUserGroups) {
      // @ts-ignore
      this.logger.debug(`[gitlab] user: ${user} found in cache, authenticated with groups:`, cachedUserGroups);
      return cb(null, cachedUserGroups.publish);
    }

    // Not found in cache, query gitlab
    this.logger.trace(`[gitlab] user: ${user} not found in cache`);

    const GitlabAPI = new Gitlab({
      url: this.config.url,
      token: password,
    });

    GitlabAPI.Users.current()
      .then(response => {
        if (user.toLowerCase() !== response.username.toLowerCase()) {
          return cb(getUnauthorized('wrong gitlab username'));
        }

        const publishLevelId = ACCESS_LEVEL_MAPPING[this.publishLevel];

        // Set the groups of an authenticated user, in normal mode:
        // - for access, depending on the package settings in verdaccio
        // - for publish, the logged in user id and all the groups they can reach as configured with access level `$auth.gitlab.publish`
        const gitlabPublishQueryParams = { min_access_level: publishLevelId };
github netlify / staticgen / scripts / repos.js View on Github external
function authenticate({ gitHubToken, gitLabToken }) {
  octokit = Octokit()
  octokit.authenticate({ type: 'token', token: gitHubToken })
  gitlab = new Gitlab({ personaltoken: gitLabToken })
}
github netlify / staticgen / scripts / fetch-archive.js View on Github external
function init(tokens) {
  github = githubInit(tokens.githubToken)
  gitlab = new Gitlab({ personaltoken: tokens.gitlabToken })
  getTwitterFollowers = twitterFollowersCount({
    consumer_key: tokens.twitterConsumerKey,
    consumer_secret: tokens.twitterConsumerSecret,
    access_token_key: tokens.twitterAccessTokenKey,
    access_token_secret: tokens.twitterAccessTokenSecret,
  })
}
github paulrobertlloyd / indiekit / packages / publisher-gitlab / lib / update-file.js View on Github external
module.exports = async (opts, path, content, message) => {
  const gitlab = new Gitlab({
    host: opts.instance,
    token: opts.token
  });

  content = Buffer.from(content).toString('base64');
  const response = await gitlab.RepositoryFiles.edit(
    opts.projectId,
    path,
    opts.branch,
    content,
    message, {
      encoding: 'base64'
    }
  ).catch(error => {
    throw new Error(error);
  });
github ruslang02 / atomos / apps / official / market / market.js View on Github external
async function login() {
	if (access) {
		try {
			api = new GitLab({
				url: BASE_SERVER,
				oauthToken: access.access_token
			});
			console.log(api);
			currentUser = await api.Users.current();
			await renderUser();
			return;
		} catch (e) {
			console.log("Login using access_token failed. Proceeding with OAuth2", e, access);
		}
	} else
		console.log("First time login. Welcome in!");
	let modal = document.createElement("div");
	modal.dialog = document.createElement("form");
	modal.content = document.createElement("main");
	modal.dialog.className = "modal-dialog modal-dialog-centered";
github GetPublii / Publii / app / back-end / modules / deploy / gitlab-pages.js View on Github external
this.repository = this.deployment.siteConfig.deployment.gitlab.repo;
        this.user = this.deployment.siteConfig.deployment.gitlab.user;
        this.branch = this.deployment.siteConfig.deployment.gitlab.branch;
        this.remoteFilesList = [];
        this.filesToRemove = [];
        this.filesToUpdate = [];
        this.filesToUpload = [];
        this.waitForTimeout = true;
        let token = this.deployment.siteConfig.deployment.gitlab.token;
        let account = slug(this.deployment.siteConfig.name);

        if (token === 'publii-gl-token ' + account) {
            token = await passwordSafeStorage.getPassword('publii-gl-token', account);
        }

        this.client = new Gitlab({
            url: this.deployment.siteConfig.deployment.gitlab.server,
            token: token
        });

        this.setUploadProgress(6);
        console.log('(!) CLIENT CREATED');

        process.send({
            type: 'web-contents',
            message: 'app-connection-in-progress'
        });

        this.deployment.setInput();
        this.deployment.setOutput(true);
        this.deployment.prepareLocalFilesList();
        this.setUploadProgress(7);
github reimagined / resolve / trigger-on-pull-request / index.js View on Github external
async function main({ gitlab, github, refreshTime }) {
  const PipelinesService = new Gitlab.Pipelines({
    token: gitlab.personalAccessToken
  })

  try {
    await cancelPipelines(PipelinesService)
  } catch (_) {
    try {
      await cancelPipelines(PipelinesService)
    } catch (error) {
      console.error(error)
    }
  }

  octokit.authenticate({
    type: 'token',
    token: github.token
github btoles / semantix / src / create-release.js View on Github external
module.exports = async nextVersion => {
    if (GITHUB_TOKEN && GITLAB_TOKEN) {
        throw new Error('Found both GitLab and GitHub token, please supply one or the other.');
    }
    if (GITHUB_TOKEN) {
        const gitHub = new octokit({
            baseUrl: GITHUB_URL,
            type: 'token',
            token: GITHUB_TOKEN
        });
    }
    if (GITLAB_TOKEN) {
        const gitLab = new Projects({
            url: GITLAB_URL,
            token: GITLAB_TOKEN
        });
    }
}
github kube-HPC / hkube / core / api-server / lib / service / githooks / git-service.js View on Github external
async getGitlabLastCommit({ url, branchName = 'master', token = null }) {
        const { host, owner, repo } = this._parseGithubUrlRepo(url);

        const services = new ProjectsBundle({
            host,
            token
        });

        const lastCommit = await services.Commits.all(`${owner}/${repo}`, {
            perPage: 1,
            maxPages: 1,
            showPagination: true,
            ref_name: branchName
        });
        return lastCommit.data[0];
    }

gitlab

Full NodeJS implementation of the GitLab API. Supports Promises, Async/Await.

MIT
Latest version published 4 years ago

Package Health Score

67 / 100
Full package analysis