Skip to content

Instantly share code, notes, and snippets.

View foutoucour's full-sized avatar

Jordi Riera foutoucour

View GitHub Profile
@foutoucour
foutoucour / gist:cb695e9051b41b665607b96032d0c464
Last active October 8, 2020 17:45
github api async python3
import asyncio
import collections
import os
from pprint import pprint
import aiohttp
from gidgethub.aiohttp import GitHubAPI
async def get_repo(client, user):
@foutoucour
foutoucour / getBranchName.groovy
Created November 6, 2017 14:39
Get Real Branch Name in Jenkins during PRs
def getBranchName() {
def branchName = env.BRANCH_NAME
// if it is a PR, then we need to find back the name of the real branch from the commit.
if (branchName.contains("PR-")) {
repoUrl = sh(returnStdout: true, script: "echo ${env.CHANGE_URL} | sed 's/pull.*//'").trim()
// simulate a git fetch
// but stays on the current branch
git branch: branchName, credentialsId: 'github_username_password', url: repoUrl
// store the current commit
gitCommit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()