You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/plugins/adaptive_cards.md
+44-36Lines changed: 44 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,71 +20,79 @@ Here is an example of what a card for the Docker plugin looks like :
20
20
21
21

22
22
23
-
This card allows you to see, at a glance, all of the important information pertaining to the image generated during the execution of the docker plugin.
23
+
This card allows you to see, at a glance, all of the important information pertaining to the image generated during the execution of the docker plugin.
# How do I add adaptive cards support to my plugin?
34
37
35
38
Plugin Cards are built upon the open adaptive cards format . This makes it much easier for a plugin developer to add enhanced output functionality without requiring any changes to the Drone Server.
36
39
37
40
A card is made up of a template (what the user sees) and output from a plugin (raw data from the build). These are combined by Drone to display the card in the Drone UI.
38
41
39
-
During the plugin’s execution, Drone downloads the plugin template. An example of what a template looks like can be found here and it is downloaded when rendering the card.
42
+
During the plugin’s execution, Drone downloads the plugin template. An example of what a template looks like can be found here and it is downloaded when rendering the card.
40
43
41
44
Below is the JSON payload that is generated by the docker plugin. This is the raw information that appears on the card:
To get started you first want to think about the information you wish to display on-screen & how it should look. This becomes the card template. The easiest way to create it is by using this adaptive cards designer.
68
72
69
73
The docker template in this example is hosted and served using Github pages.
74
+
70
75
Mention the directory structure of the plugin
71
-
- /docs/template.json
72
-
- /docs/sample_data.json
76
+
77
+
- /docs/template.json
78
+
- /docs/sample_data.json
73
79
74
80
## Card Input
81
+
75
82
This assumes that your plugin has been written in Golang but it could be written in any other language. As long as the JSON output is created correctly.
76
83
77
84
The structure of a card struct is as follows. This is what is written to the logs for the runner to extract and publish information to the Drone server.
78
85
79
-
{{< highlight golang "linenos=table" >}}
86
+
```go {linenos=table}
80
87
CardInput struct {
81
88
Schemastring`json:"schema"`// template url
82
89
Data json.RawMessage`json:"data"`// template data
83
90
}
84
-
{{< / highlight >}}
91
+
```
85
92
86
93
The following encodes the card data in order for the runner to extract it from the logs:
87
-
{{< highlight go "linenos=table" >}}
94
+
95
+
```go {linenos=table}
88
96
funcwriteCardTo(outio.Writer, data []byte) {
89
97
encoded:= base64.StdEncoding.EncodeToString(data)
90
98
io.WriteString(out, "\u001B]1338;")
@@ -93,11 +101,11 @@ func writeCardTo(out io.Writer, data []byte) {
93
101
io.WriteString(out, "\n")
94
102
}
95
103
}
96
-
{{< / highlight >}}
104
+
```
97
105
98
-
This code allows the plugin to support both CI & Drone. Once the card input struct has been created, it must be written to “dev/stdout”.
106
+
This code allows the plugin to support both CI & Drone. Once the card input struct has been created, it must be written to “dev/stdout”.
0 commit comments