Slide 21
Slide 21 text
Azure Functions
const azdev = require('azure-devops-node-api');
const orgUrl = `https://dev.azure.com/${process.env.AZURE_DEVOPS_PROJECT_NAME}`;
const token = process.env.AZURE_DEVOPS_API_KEY;
const projectName = 'github-pages';
module.exports = async function (context, req) {
context.log('JavaScript HTTP trigger function processed a request.');
let authHandler = await azdev.getPersonalAccessTokenHandler(token);
let connection = await new azdev.WebApi(orgUrl, authHandler);
let vstsBuild = await connection.getBuildApi();
const builds = await vstsBuild.getBuilds(projectName);
const build = await vstsBuild.getBuild(builds[0].id, projectName);
const res = await vstsBuild.queueBuild(build, projectName);
context.res = {
// status: 200, /* Defaults to 200 */
body: res.status
};
};
ͬͱ؆୯ͳํ๏͕͋Εڭ͍͑ͯͩ͘͞