TFS 2017 Build Templates Property needs attention - tfs

I'm currently trying to create default build templates on Microsoft Team Foundation Server 2017.
I created a template via the REST API and it's going well overall.
But... One Question.
If anybody creates a build with my template, I wanna show him which settings he have to set up to run the build well. Until now I've done this:
The JSON looks like this:
...,
{
"enabled": true,
"continueOnError": false,
"alwaysRun": false,
"displayName": "NuGet Packager ",
"timeoutInMinutes": 0,
"task": {
"id": "333b11bd-d341-40d9-afcf-b32d5ce6f24b",
"versionSpec": "0.*",
"definitionType": "task"
},
"inputs": {
"searchPattern": "<chooseProject>",
"outputdir": "",
"includeReferencedProjects": "false",
"versionByBuild": "false",
"versionEnvVar": "",
"requestedMajorVersion": "1",
"requestedMinorVersion": "0",
"requestedPatchVersion": "0",
"configurationToPack": "$(BuildConfiguration)",
"buildProperties": "",
"nuGetAdditionalArgs": "",
"nuGetPath": ""
}
}...
How can I change the json to make it look like this?

Just need to add a "required": true, in the inputs.
You could also refer the source code of this task in github--PublishBuildArtifacts

Related

Azure DevOps Extension custom service endopint for ID/KEY

I am developing Azure DevOps extension which contain service endpoint to hold secret ID/KEY. My requirement is to have endpoint just consist of Connection name, ID ,and Key in it.I have gone trough list of provided endpoints in Microsoft but I couldn't find suitable option to satisfy my requirement.
https://learn.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?view=vsts#sep-ssh
closest solution I found is as below . But it contains input box for server URL(Which I need to omit (in this example though I don't define server URL it displays in popup dialog)). Please refer below image.
Is it possible to remove Server URL from above dialog box Or it there better endpoint type I can use for this requirement? please be kind enough to share some light with me.
You'll need to create a custom service type, that will allow you to show/hide the individual text boxes. You can find an example in the Azure DevOps Extension Tasks which I maintain.
You define custom service endpoint types in the vss-extension.json along with your other extension points:
{
"id": "vsts-marketplace-endpoint-type",
"type": "ms.vss-endpoint.service-endpoint-type",
"targets": [
"ms.vss-endpoint.endpoint-types"
],
"properties": {
"name": "VstsMarketplacePublishing",
"displayName": "Visual Studio Marketplace",
"url": {
"displayName": "Marketplace URL",
"value": "https://marketplace.visualstudio.com",
"isVisible": "false"
},
"helpMarkDown": "Required permissions: <ul><li><b>Publish</b>: All accessible organisations, Marketplace (Publish)</li><li><b>Share</b>: All accessible organisations, Marketplace Publish</li><li><b>Install</b>: All accessible organisations or a specific organisation, Extensions (read and manage), Marketplace (acquire)</li><li><b>Query Version</b>: All accessible organisations, Marketplace (read)</li><li><b>Is Valid Extension</b>: All accessible organisations, Marketplace (read)</li></ul><br/><a href='https://www.visualstudio.com/docs/setup-admin/team-services/use-personal-access-tokens-to-authenticate'>More information</a>.",
"authenticationSchemes": [
{
"type": "ms.vss-endpoint.endpoint-auth-scheme-basic",
"inputDescriptors": [
{
"id": "username",
"name": "Username",
"description": "Username",
"inputMode": "textbox",
"isConfidential": false,
"validation": {
"isRequired": false,
"dataType": "string",
"maxLength": 300
},
"values": {
"inputId": "username",
"isDisabled": true,
"defaultValue": ""
}
},
{
"id": "password",
"name": "Personal access token",
"description": "Azure DevOps personal access token.",
"inputMode": "passwordbox",
"isConfidential": true,
"validation": {
"isRequired": true,
"dataType": "string",
"maxLength": 300
}
}
]
}
]
}
},
You may find other extensions that set or configure the authentication dialog on GitHub, there are quite a few. Useful docs are here in an old blog post.

Modify Task.json at build step design time

i wanted to modify task.json on runtime means when i configure my CI task in vsts or tfs.
I created an extension that contribute a build task.
Through this build task i wanted to do something like this, i have done in jenkins. Please Refer screenshot:
1-Requirement) in this image we add global variable(fields) at runtime on clicking Add Global Variables button. It generates two fields one for GVName and another for its value.
2-Requirement) When we select global variable then respective value field change at runtime means it can be dropbox(picklist) or input field that depends on GV type.
3-Requirement) On Job design time we make an ajax call to server that return true/false on based of value we shows error like in image 2.
Is these requirements are feasible in VSTS task.json? If yes, can you help me to solve this.
No, but it can list the available items that returned from the server.
For example:
"inputs": [
{
"name": "APIURL",
"type": "connectedService:Generic",
"label": "API URL",
"required": true,
"helpMarkDown": ""
},
{
"name": "List1",
"type": "pickList",
"label": "List4",
"defaultValue": "",
"required": false,
"helpMarkDown": ""
}
],
"sourceDefinitions": [
{
"target": "List1",
"endpoint": "home/jsontest",
"selector": "jsonpath:$[*].id",
"authKey": "$(APIURL)"
}
],
A thread that may benefit you: Using a web API in task.json to fill picklists buildtask

Openedx import fails with "'NoneType' object has no attribute 'data_dir'" message

I created a course on my personal openedx instance. Then exported it, and tried to import it into an institutional platform but got the error :
There was an error while importing the new course to our database.
'NoneType' object has no attribute 'data_dir'
enter image description here
How to solve this ?
Edit: also, duplicated sections are not exported properly. You must create them my click on the create button, then move relevant content into those.
You need to fix some minor issue in the archive.
Within your archive, edit /course/policies/course/policy.json.
Somewhere within it there is a tabs object.
"tabs": [
{
"course_staff_only": false,
"name": "Home",
"type": "course_info"
},
{
"course_staff_only": false,
"name": "Course",
"type": "courseware"
},
...
]
Within it, the type courseware whould be first.
"tabs": [
{
"course_staff_only": false,
"name": "Course",
"type": "courseware"
},
{
"course_staff_only": false,
"name": "Home",
"type": "course_info"
},
...
]
Import then works :
enter image description here

Activiti - Get Process Instance Details" Java API

I am using Activiti 5.12. As provided, in its user guide, REST API to get he details of a process instance is :
GET /process-instance/{processInstanceId}
Its response is something like this :
{
"id": "2",
"processDefinitionId": "financialReport:1",
"businessKey": "55",
"startTime": "2010-10-13T14:54:26.750+02:00",
"startActivityId": "startFinancialAnalysis",
"startUserId": "kermit",
"completed": false,
"tasks": [
{
"taskId": "3",
"taskName": "Analyze report",
"owner": null,
"assignee": "Kermit",
"startTime": "2010-10-13T14:53:26.750+02:00",
"completed": false
}
],
"activities": [
{
"activityId": "4",
"activityName": "Get report",
"activityType": "ServiceTask",
"startTime": "2010-10-13T14:53:25.950+02:00",
"completed": true,
"duration": 200
}
],
"variables": [
{
"variableName": "reportName",
"variableValue": "classified.pdf"
}
],
"historyVariables": [
{
"variableName": "reportName",
"variableValue": "classified.pdf",
"variableType": "String",
"revision": 1,
"time": "2010-10-13T14:53:26.750+02:00"
}
]
}
A JAVA API for the same is also provided, which is :
ProcessEngines.getProcessEngine(configuredProcessEngineName).getHistoryService().createHistoricProcessInstanceQuery().processInstanceId("somevalue").singleResult()
This Java API does not work, as teh return type HistoricProcessInstance does not have the method to get the task list.
My objective is to get the current state of a process instance, i.e which task it's presently at.
The REST API lists all tasks that process instance has carried out and the last task of the list is the one it's currently executing, as its property completed is false.
I want to achieve the same from java code.
Can you please help me out. Any alternative way to get to my objective is also fine with me.
You can use another query of HistoricService API:
List<HistoricTaskIntance> taskList = getHistoryService()
.createHistoricTaskInstanceQuery()
.processInstanceId(processInstanceId)
.list()
The current task status can be defined by HistoricTaskInstance.getEndTime() that will return null for open tasks.
I have tried this way out.
SELECT NAME_ FROM act_hi_taskinst where PROC_INST_ID_= 1000 and END_TIME_ IS NULL;"
act_hi_taskinst contains history tasks for each and every instance.
If the process with instance id is completed then you wont get any result, so you can check that condition before moving forward.
I have run this piece of SQL Statement to get the required task name.
The answer given by #Mike also meets the objective. Even here also you have to check whether process is incomplete.

How can I publish a Simperium note?

How can I publish a note using the PublishURL propertie?
{"tags": [], "deleted": false, "shareURL": "", "systemTags": [], "content": "updated note with new modification time", "publishURL": "", "modificationDate": 1341563318.0, "creationDate": 1335390338.091453}
The publish functionality still uses the old API currently - you can use the following call to publish a note
GET https://simple-note.appspot.com/api2/data/[note key]/publish
The response should contain a publishkey:
{ "publishkey" : "xdAa5s" }
You can use a X-Simperium-Token header like in Simperium to authenticate.

Resources