How to retrieve build attachment from VSTS release summary tab - azure-devops

I need to retrieve a build attachment attached using (##vso[task.addattachment]value) from release summary page (ms.vss-releaseManagement-web.release-details-summary-tab). Please point me to any references to achieve this.
Thanks in advance.

Yes, you need to do followings things to get this:
1.Get the related build id of the release via getConfiguration():
var c = VSS.getConfiguration();
c.onReleaseChanged(function (release) {
release.artifacts.forEach(function (art) {
var buildid = art.definitionReference.version.id;
});
});
2.Use the build ID you get in previous step to get the detailed build information via getBuild(). And then you can get the planid from the build information.
3.Use the planid to get the uploaded file via getPlanAttachments().

Related

Accessing Raw Gamer Profile Picture

I am using the new XBox Live API for C# (https://github.com/Microsoft/xbox-live-api-csharp) for official access through a UWP app.
I am able to authenticate fine and reference the XBox Live user in context.
SignInResult result = await user.SignInAsync();
XboxLiveUser user = new XboxLiveUser();
Success! However, I can't seem to find an appropriate API call to return XboxUserProfile or XboxSocialProfile. Both of these classes contain URLs to the player's raw gamer pics. After reviewing MSDN documentation and the GH library it isn't clear to me how this is achieved. Any help is greatly appreciated.
The below sample should work if you meet the following pre requisits:
Reference the Shared Project that contains the API from your project and don't reference the "Microsoft.Xbox.Services.UWP.CSharp" project
Copy all source code files from the "Microsoft.Xbox.Services.UWP.CSharp" project into your project
Include the Newtonsoft.Json NuGet package into your project
Steps 1 & 2 are important as this allows you to access the "internal" constructors which otherwise would be protected from you.
Code to retrieve the profile data:
XboxLiveUser user = new XboxLiveUser();
await user.SignInSilentlyAsync();
if (user.IsSignedIn)
{
XboxLiveContext context = new XboxLiveContext(user);
PeopleHubService peoplehub = new PeopleHubService(context.Settings, context.AppConfig);
XboxSocialUser socialuser = await peoplehub.GetProfileInfo(user, SocialManagerExtraDetailLevel.None);
// Do whatever you want to do with the data in socialuser
}
You may still run into an issue like I did. When building the project you may face the following error:
Error CS0103 The name 'UserPicker' does not exist in the current
context ...\System\UserImpl.cs 142 Active
If you get that error make sure you target Win 10.0 Build 14393.

What object returns from TFS2015 RestAPI

I'm using TFS 2015 rest api in order to retrieve build definitions and builds details using those calls:
definitions:
http:///tfs/DefaultCollection//_apis/build/definitions?name=ampm&api-version=2.0
builds:
http:///tfs/DefaultCollection//_apis/build/builds?definition=DigitalVault_Automation&statusFilter=completed&$top=10&api-version=2.0
I get a rich JSON and I wonder if there is a standard Class that I can deserialize those JSONs to.
Couldn't find any reference in Microsoft's guide though.
You could use install this Nuget package for your project and in the package. The assemblies in this package has already help you transfer the json data to the corresponding object. For example, to get something about build, you could use the Microsoft.TeamFoundation.Build.WebApi assembly. To get a build definition:
var u = new Uri("http://serverName:8080/tfs/MyCollection/");
VssCredentials c = new VssCredentials(new Microsoft.VisualStudio.Services.Common.WindowsCredential(new NetworkCredential("userName", "password", "domain")));
var connection = new VssConnection(u, c);
var buildServer = connection.GetClient<BuildHttpClient>();
BuildDefinition builddef = buildServer.GetDefinitionAsync("AgileMttGreen",10).Result;
Console.WriteLine(builddef.Name);
I use Json.NET to manipulate JSON data.
You can find plenty of examples in this library web site.

How to fix type error while using gulp-filter?

I am mimicking the code from John Papa's outstanding Pluralsight course on Gulp.
When I use the code as shown in John's course:
.pipe(jsFilter)
.pipe($.uglify())
.pipe(jsFilter.restore())
I get an error on the 3rd line of code:
TypeError: Object #<StreamFilter> has no method 'restore'
When I use the code as shown in the readme from gulp-filter
.pipe(jsFilter)
.pipe($.uglify())
.pipe(jsFilter.restore)
I get an error that it can't pipe to undefined.
Based on what I can find online, both of these patterns are working for others. Any clues as to why this might be happening?
Here is the whole task, if that helps and the console logging indicates that everything if fine until the filter restore call.
Here is the entire task if that helps:
gulp.task('build-dist', ['inject', 'templatecache'], function() {
log('Building the distribution files in the /dist folder');
var assets = $.useref.assets({searchPath: './'});
var templateCache = config.temp + config.templateCache.file;
var jsFilter = $.filter('**/*.js');
return gulp
.src(config.index)
.pipe($.plumber({errorHandler: onError}))
.pipe($.inject(gulp.src(templateCache, {read: false}), {
starttag: '<!-- inject:templates:js -->'
}))
.pipe(assets)
.pipe(jsFilter)
.pipe($.uglify())
.pipe(jsFilter.restore())
.pipe(assets.restore())
.pipe($.useref())
.pipe(gulp.dest(config.dist));
});
The way restore works has changed between the 2.x and 3.x release of gulp-filter.
It seems you're using the 3.x branch, so in order to use restore you'll have to set the restore option to true when defining the filter:
var jsFilter = $.filter('**/*.js', {restore: true});
Then you'll be able to do
.pipe(jsFilter.restore)
For more information, check out this section of the documentation for the latest version of gulp-filter:
https://github.com/sindresorhus/gulp-filter/tree/v3.0.1#restoring-filtered-files

How to get articleId dynamically?

I am using Asset Publisher and need to dynamically get the articleId of the latest journal article published.
I am using in abstracts.jsp hook:
version=JournalArticleLocalServiceUtil.getLatestVersion(assetRenderer.getGroupId(), "14405");
journalArticle = JournalArticleLocalServiceUtil.getArticle(assetRenderer.getGroupId() , "14405",version);
I have hardcoded the articleId here.
How do I avoid this??
Kindly help.
Thanks.
Use a dynamic query to get the latest Article from JournalArticleLocalServiceUtil maybe you can use ProjectionFactoryUtil.max("createDate"); to get the latest Date
DynamicQueryFactoryUtil.forClass(JournalArticle.class)
.add(ProjectionFactoryUtil.max("createDate"))
.add(PropertyFactoryUtil.forName("groupId").eq(new Long(groupId)));
List results =JournalArticleLocalServiceUtil.dynamicQuery(query);`

Get Workspace source control folder in the workflow as an argument

I am creating a custom activity for my build in TFS 2010, and I need to pass the activity the source control folder for the current build definition.
I need this as it is defined on the Workspace screen in the build definition screen, such as a string like "$/Project/Folder".
I can't find the appropriate property to pass as an argument to my activity. I've found BuildDetail.TeamProject just returned "Project", but haven't had much success with anything else.
Any help appreciated.
You can create a property like
public InArgument<Workspace> CurrentWorkspace { get; set;}
In the overriden execute method you can access the workspace like
var workspace = context.GetValue<Workspace>(this.CurrentWorkspace);
foreach (var folder in workspace.Folders)
{
//
}
To use the Workspace type you need an using to
using Microsoft.TeamFoundation.VersionControl.Client;
For detailed information look at Ewald Hofmans blog