如何使用Wiql查询VSTS工作项

时间:2016-09-26 12:10:48

标签: tfs azure-devops azure-pipelines azure-pipelines-build-task azure-devops-rest-api

我需要使用vsp-node-api包中的Wiql查询VSTS工作项,请尽可能提供任何示例。

2 个答案:

答案 0 :(得分:3)

有关详细信息,请参阅以下代码:

library(expm)
args = commandArgs(trailingOnly=TRUE)

if (length(args) !=  4){
    stop("Usage: Rscript GL2_cyclic 11 12 21 22", call.=FALSE)
}

for(i in 1:length(args)){
    if(length(grep("/",args[i])) != 0){
        temp <- as.integer(unlist(strsplit(args[i],"/")))
        args[i] <- temp[1]/temp[2]
    }
}

args <- as.numeric(args)

gen <- matrix(args,nrow=2,ncol=2)
id <- matrix(c(1,0,0,1),nrow=2,ncol=2)

main <- function(A){
    i <- 1
    matrixlist <- list()
    if(det(A) == 0){
        stop("Matrix is not invertible", call.=FALSE)
    }
    else{
    while(!(identical(A%^%i,id))){
            matrixlist[[i]] <- A%^%i
                i <- i+1
            }
            if(identical(A%^%i,id)){
                matrixlist[[i]] <- A%^%i
            }
        print(matrixlist)
        sprintf("Order of generator = %d",i)
    }
}

main(gen)

答案 1 :(得分:0)

这是我使用Javascript而不是Typescript的方法。 大声疾呼Eddie Chen带领我朝正确的方向前进。

// file - models/witModel.js

var azdev = require("azure-devops-node-api");

var Model = function(){};

Model.prototype.getWiqlQuery = function(wiqlQuery, teamName){
    return new Promise(function(resolve, reject){   

        const orgUrl = process.env.ADOURI; // ex.  https://dev.azure.com/<your org>
        const token = process.env.ADOPAT;   // Your personal access token
        const teamProject = process.env.ADOPROJ;// Team Project     

        let authHandler = azdev.getPersonalAccessTokenHandler(token); 
        let connection = new azdev.WebApi(orgUrl, authHandler);

        connection.getWorkItemTrackingApi().then(function(witAPI){
            var teamContext = {project: teamProject, team: teamName };
            witAPI.queryByWiql(wiqlQuery, teamContext).then(function(queryResult){
                resolve(queryResult);
            }).catch(function(err){reject(err)});
        }).catch(function(err){
            reject(err);
        });

    });
};


module.exports = new Model();

这就是我的用法。

// usage - the above code was saved in a module called witModel.js
// feel free to put the module where you need to.
var witModel = require("./models/witModel.js");

// form query and set the value of the teame to query
var query = {query: "your wiql query"};
var team = "team name in Azure DEvops";

// call the promise and handle resolve/reject - then/catch
witModel.getWiqlQueryResuults(query,team).then(function(data){
    console.log(data);
}).catch(function(err){
    console.log(err)
});