* changed single expression plugin upload to individual calls checking response. fixes problems with no uploads on Ubuntu 16.04
* Updated error message as requested by @levb on #discussion_r275448965
* removed double PLUGIN_VERSION ref
* added --post301 --location to curl invocation in ./build/bin/manifest apply
mkdir -p server/dist;
cd server && env GOOS=linux GOARCH=amd64 /usr/local/go/bin/go build -o dist/plugin-linux-amd64;
cd server && env GOOS=darwin GOARCH=amd64 /usr/local/go/bin/go build -o dist/plugin-darwin-amd64;
cd server && env GOOS=windows GOARCH=amd64 /usr/local/go/bin/go build -o dist/plugin-windows-amd64.exe;
cd webapp && /usr/local/bin/npm run build;
> webapp@0.0.1 build /home/skawtus/workspace/mattermost-plugin-sample/webapp
> webpack --mode=production
Hash: f6fcda45461a2f57b51b
Version: webpack 4.16.1
Time: 509ms
Built at: 2019-04-16 09:56:33
Asset Size Chunks Chunk Names
main.js 1.61 KiB 0 [emitted] main
[0] multi ./src/index.js 28 bytes {0} [built]
[1] ./src/index.js 1.28 KiB {0} [built]
[2] ./src/manifest.js 174 bytes {0} [built]
rm -rf dist/
mkdir -p dist/com.mattermost.sample-plugin
cp plugin.json dist/com.mattermost.sample-plugin/
cp -r assets dist/com.mattermost.sample-plugin/
cp -r public/ dist/com.mattermost.sample-plugin/
mkdir -p dist/com.mattermost.sample-plugin/server/dist;
cp -r server/dist/* dist/com.mattermost.sample-plugin/server/dist/;
mkdir -p dist/com.mattermost.sample-plugin/webapp/dist;
cp -r webapp/dist/* dist/com.mattermost.sample-plugin/webapp/dist/;
cd dist && tar -cvzf com.mattermost.sample-plugin-0.1.0.tar.gz com.mattermost.sample-plugin
com.mattermost.sample-plugin/
com.mattermost.sample-plugin/webapp/
com.mattermost.sample-plugin/webapp/dist/
com.mattermost.sample-plugin/webapp/dist/main.js
com.mattermost.sample-plugin/assets/
com.mattermost.sample-plugin/assets/.gitkeep
com.mattermost.sample-plugin/plugin.json
com.mattermost.sample-plugin/server/
com.mattermost.sample-plugin/server/dist/
com.mattermost.sample-plugin/server/dist/plugin-darwin-amd64
com.mattermost.sample-plugin/server/dist/plugin-windows-amd64.exe
com.mattermost.sample-plugin/server/dist/plugin-linux-amd64
com.mattermost.sample-plugin/public/
com.mattermost.sample-plugin/public/hello.html
plugin built at: dist/com.mattermost.sample-plugin-0.1.0.tar.gz
Installing plugin via API
OK.
* reverted to original request sequence, combine with post301 & location flags to curl
|
||
|---|---|---|
| .circleci | ||
| assets | ||
| build | ||
| public | ||
| server | ||
| webapp | ||
| .editorconfig | ||
| .gitignore | ||
| CHANGELOG.md | ||
| go.mod | ||
| go.sum | ||
| LICENSE | ||
| Makefile | ||
| plugin.json | ||
| README.md | ||
Sample Plugin 
This plugin serves as a starting point for writing a Mattermost plugin. Feel free to base your own plugin off this repository.
Getting Started
Shallow clone the repository to a directory outside of $GOPATH matching your plugin name:
git clone --depth 1 https://github.com/mattermost/mattermost-plugin-sample com.example.my-plugin
Edit plugin.json with your id, name, and description:
{
"id": "com.example.my-plugin",
"name": "My Plugin",
"description": "A plugin to enhance Mattermost."
}
Build your plugin:
make
This will produce a single plugin file (with support for multiple architectures) for upload to your Mattermost server:
dist/com.example.my-plugin.tar.gz
There is a build target to automate deploying and enabling the plugin to your server, but it requires configuration and http to be installed:
export MM_SERVICESETTINGS_SITEURL=http://localhost:8065
export MM_ADMIN_USERNAME=admin
export MM_ADMIN_PASSWORD=password
make deploy
Alternatively, if you are running your mattermost-server out of a sibling directory by the same name, use the deploy target alone to unpack the files into the right directory. You will need to restart your server and manually enable your plugin.
In production, deploy and upload your plugin via the System Console.
Q&A
How do I make a server-only or web app-only plugin?
Simply delete the server or webapp folders and remove the corresponding sections from plugin.json. The build scripts will skip the missing portions automatically.
How do I include assets in the plugin bundle?
Place them into the assets directory. To use an asset at runtime, build the path to your asset and open as a regular file:
bundlePath, err := p.API.GetBundlePath()
if err != nil {
return errors.Wrap(err, "failed to get bundle path")
}
profileImage, err := ioutil.ReadFile(filepath.Join(bundlePath, "assets", "profile_image.png"))
if err != nil {
return errors.Wrap(err, "failed to read profile image")
}
if appErr := p.API.SetProfileImage(userID, profileImage); appErr != nil {
return errors.Wrap(err, "failed to set profile image")
}