I have a Microsoft Teams webhook which will alert me when a TeamCity build has failed. I am wondering how I would be able to get the URL of the current TeamCity build so I can pass this information to my webhook.
Only using parameters at hand, you could build the uri back to the build log:
%teamcity.serverUrl%/viewLog.html?buildId=%teamcity.build.id%
If you're using a MessageCard, this would make the potentialAction field of the payload to something like:
"potentialAction": [
{
"#type": "OpenUri",
"name": "View in TeamCity",
"targets": [
{
"os": "default",
"uri": "%teamcity.serverUrl%/viewLog.html?buildId=%teamcity.build.id%"
}
]
}
]
Anything fancier would require a call to the TeamCity REST API
Related
Trying to manage a conversation flow by "Go to action" action (sorry for tautology). All tests to call all types of actions by ID from *.dialog return error.
ClassName:"System.ArgumentException" Message:"GotoAction: could not find an action of "cW0raQ"."
How reference looks
I didn't find any mention in the documentation how to work with this action, therefore it must be pretty simple, but I can't catch the correct way.
As usually, answer myself.
Had a look at MS tests in their repo https://github.com/microsoft/botbuilder-dotnet/ and found out that it requires creating ID for action manually. Automatic $designer.id doesn't work.
{
"$kind": "Microsoft.GotoAction",
"$designer": {
"id": "uFOn5P"
},
"actionId": "targetID"
},
...
{
"id": "targetID",
"$kind": "Microsoft.SendActivity",
"$designer": {
"id": "oWxpDh",
"comment": "",
"name": "GoTo test"
},
"activity": "${SendActivity_oWxpDh()}"
}
Moreover, this action works in scope of trigger only, not dialog.
My objective is to write a script that promotes a "stage" application in our Heroku pipeline to production, but only if there are any changes to promote.
I can promote without issues by using:
// POST /pipeline-promotions
{
"pipeline": {
"id": "<pipeline-id>"
},
"source": {
"app": {
"id": "<stage-app-id>"
}
},
"targets": [
{
"app": {
"id": "<production-id>"
}
}
]
}
My issues is that if I execute this, without any changes are present, the release actions are still started on the production application.
In other words, how can I determine if any changes are available for promotion - just like heroku does in their GUI?
Thanks to Heroku support, I managed to figure this out.
It can be done by comparing the slug id's when looking at pipelines/<pipeline-id>/latest-releases.
If the slug-ids are the same, there are no changes to promote.
When a spinnaker pipeline fails, we can see the following:
Spinnaker Alerts Bot APP [3:24 PM]
Stage failed for APP_NAME
Stage STAGE_NAME for APP_NAME's PIPELINE_NAME has failed
OTHER STUFF FROM NOTIFICATION CONFIG PANEL OF STAGE
Spinnaker Today at 3:24 PM
It's easy to configure the "OTHER STUFF", but what about the first 3 lines, not seeing a place in Spinnaker UI to do this, perhaps in the configuration files on server?
Here is an update for more recent version of spinnaker, 1.16.5: the custom message is editable for each notification type (start, fail, done). Doesn't seem that you can put html in it, but you can put markup. I don't know at what version of spinnaker the contents of this post got implemented, I just know it holds for 1.16.5.
Also once you have configured one of your pipelines to use Notification, you can copy the JSON for the notification to other pipelines to easily configure them identically (or as a starting point).
So I have the following JSON for our Slack notifications, notice the pipeline parameters used and their bold markup:
"notifications": [
{
"address": "spinnaker-notifications",
"level": "pipeline",
"message": {
"pipeline.failed": {
"text": "SERVICE_NAME: *${ parameters['SERVICE_NAME'] }*\nSERVICE_VERSION: *${ parameters['SERVICE_VERSION'] }*"
},
"pipeline.starting": {
"text": "SERVICE_NAME: *${ parameters['SERVICE_NAME'] }*\nSERVICE_VERSION: ${ parameters['SERVICE_VERSION'] }"
}
},
"type": "slack",
"when": [
"pipeline.failed"
]
}
],
The message text is easy to configure via the Notifications dialog, just the JSON contains the embedded \n etc.
It's not documented, but if you edit the JSON of the notification, you can add a customMessage field, and that will override the default three-line message.
For example, change the notifications field in your stage JSON to:
"notifications": [
{
"address": "my-slack-channel",
"customMessage": "this will replace all three of the standard message lines, and can contain HTML",
"level": "stage",
"type": "slack",
"when": [
"stage.failed"
]
}
]
and you'll see:
Spinnaker Alerts Bot APP [3:24 PM]
this will replace all three of the standard message lines, and can contain HTML
Spinnaker Today at 3:24 PM
I followed the steps documented here to convert my existing ARM template to use the commonname setting instead of thumbprint. The deployment was successful and I was able to connect to the Service Fabric Explorer using my browser after the typical certificate selection popup. Next, I tried to deploy an application to the cluster just like I had been previously. Even though I can see the cluster connection endpoint URI in the VS public service fabric application dialog, VS fails to connect to the cluster. Before, I would get a prompt to permit VS to access the local certificate. Does anyone know how to get VS to deploy an application to a service fabric cluster setup using the certificate common name?
Extracts from the MS link above:
"virtualMachineProfile": {
"extensionProfile": {
"extensions": [`enter code here`
{
"name": "[concat('ServiceFabricNodeVmExt','_vmNodeType0Name')]",
"properties": {
"type": "ServiceFabricNode",
"autoUpgradeMinorVersion": true,
"protectedSettings": {
"StorageAccountKey1": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('supportLogStorageAccountName')),'2015-05-01-preview').key1]",
"StorageAccountKey2": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('supportLogStorageAccountName')),'2015-05-01-preview').key2]"
},
"publisher": "Microsoft.Azure.ServiceFabric",
"settings": {
"clusterEndpoint": "[reference(parameters('clusterName')).clusterEndpoint]",
"nodeTypeRef": "[variables('vmNodeType0Name')]",
"dataPath": "D:\\SvcFab",
"durabilityLevel": "Bronze",
"enableParallelJobs": true,
"nicPrefixOverride": "[variables('subnet0Prefix')]",
"certificate": {
"commonNames": [
"[parameters('certificateCommonName')]"
],
"x509StoreName": "[parameters('certificateStoreValue')]"
}
},
"typeHandlerVersion": "1.0"
}
},
and
{
"apiVersion": "2018-02-01",
"type": "Microsoft.ServiceFabric/clusters",
"name": "[parameters('clusterName')]",
"location": "[parameters('clusterLocation')]",
"dependsOn": [
"[concat('Microsoft.Storage/storageAccounts/', variables('supportLogStorageAccountName'))]"
],
"properties": {
"addonFeatures": [
"DnsService",
"RepairManager"
],
"certificateCommonNames": {
"commonNames": [
{
"certificateCommonName": "[parameters('certificateCommonName')]",
"certificateIssuerThumbprint": ""
}
],
"x509StoreName": "[parameters('certificateStoreValue')]"
},
...
I found the solution for Visual Studio. I needed to add/update to the PublishProfiles/Cloud.xml file. I replaced ServerCertThumbprint with ServerCommonName, and then used the certificate CN for the new property and the existing FindValue property. Additionally, I changed the property for FindType to FindBySubjectName. I am now able to successfully connect and publish my application to the cluster.
<ClusterConnectionParameters
ConnectionEndpoint="sf-commonnametest-scus.southcentralus.cloudapp.azure.com:19000"
X509Credential="true"
ServerCommonName="sfrpe2eetest.southcentralus.cloudapp.azure.com"
FindType="FindBySubjectName"
FindValue="sfrpe2eetest.southcentralus.cloudapp.azure.com"
StoreLocation="CurrentUser"
StoreName="My" />
Sonar version : 5.3
I am making this call
https://mysonar/api/resources/index?metrics=coverage&key=test-project
However , I am not getting the coverage of test-project from this call.
But I am getting rest of the projects and their coverages.
When I just do this
https://sonaraws.kdc.capitalone.com/api/resources/index
I am able to see my test-project on the api response.
How do I drill down to a specific project and not check the other projects from the rest call to Sonar.
I am using the below api for fetching coverage. Sonarqube version - 6.7.5
Get the componentId for a project using first api listed below.
https://sonarurl/api/components/show?key=ProjectKey
https://sonarurl/api/measures/component?componentId=Ahvhjvds87373&metricKeys=coverage
Response
{
"component": {
"id": "Ahvhjvds87373",
"key": "ProjectKey",
"name": "ProjectName",
"qualifier": "TRK",
"measures": [{
"metric": "coverage",
"value": "79.3",
"periods": [{
"index": 1,
"value": "0.0"
}]
}]
}
}
The api/resources doesn't support the key parameter. You have to specify project id by using qualifiers and resource parameters.
This should work for you:
https://mysonar/api/resources/index?metrics=coverage&qualifiers=TRK&resource=test-project
Available values of the qualifiers parameter:
VW: view
SVW: sub-view
TRK: project
BRC: module
UTS: unit test
DIR: directory
FIL: file
DEV: developer