I have success upload my plugin to mattermost server(version 5.9.6,Installed on ubuntu16.04).And It shows a error message after I click upload,which goes like :This plugin failed to start. Check your system logs for errors.
the server log error is:
{“level”:“error”,“ts”:1576483016.174209,“caller”:“app/plugin.go:97”,“msg”:“Unable to activate plugin”,“plugin_id”:“mymattermostplugin”,“error”:“unable to start plugin: mymattermostplugin: fork/exec plugins/mymattermostplugin/plugin: permission denied”,“errorVerbose”:“fork/exec plugins/mymattermostplugin/plugin: permission denied\nunable to start plugin: mymattermostplugin\ngithub.com/mattermost/mattermost-server/plugin.(*Environment).Activate\n\t/go/src/github.com/mattermost/mattermost-server/plugin/environment.go:216\ngithub.com/mattermost/mattermost-server/app.(*App).SyncPluginsActiveState\n\t/go/src/github.com/mattermost/mattermost-server/app/plugin.go:95\ngithub.com/mattermost/mattermost-server/app.(*App).InitPlugins\n\t/go/src/github.com/mattermost/mattermost-server/app/plugin.go:126\ngithub.com/mattermost/mattermost-server/app.(*Server).RunOldAppInitalization.func6\n\t/go/src/github.com/mattermost/mattermost-server/app/server_app_adapters.go:143\ngithub.com/mattermost/mattermost-server/app.(*Server).InvokeConfigListeners\n\t/go/src/github.com/mattermost/mattermost-server/app/config.go:169\ngithub.com/mattermost/mattermost-server/app.(*Server).UpdateConfig\n\t/go/src/github.com/mattermost/mattermost-server/app/config.go:58\ngithub.com/mattermost/mattermost-server/app.(*App).UpdateConfig\n\t/go/src/github.com/mattermost/mattermost-server/app/config.go:62\ngithub.com/mattermost/mattermost-server/app.(*App).EnablePlugin\n\t/go/src/github.com/mattermost/mattermost-server/app/plugin.go:245\ngithub.com/mattermost/mattermost-server/api4.enablePlugin\n\t/go/src/github.com/mattermost/mattermost-server/api4/plugin.go:187\ngithub.com/mattermost/mattermost-server/web.Handler.ServeHTTP\n\t/go/src/github.com/mattermost/mattermost-server/web/handlers.go:151\ngithub.com/mattermost/mattermost-server/web.(*Handler).ServeHTTP\n\t:1\ngithub.com/mattermost/mattermost-server/vendor/github.com/gorilla/mux.(*Router).ServeHTTP\n\t/go/src/github.com/mattermost/mattermost-server/vendor/github.com/gorilla/mux/mux.go:162\ngithub.com/mattermost/mattermost-server/vendor/github.com/gorilla/handlers.recoveryHandler.ServeHTTP\n\t/go/src/github.com/mattermost/mattermost-server/vendor/github.com/gorilla/handlers/recovery.go:78\ngithub.com/mattermost/mattermost-server/vendor/github.com/gorilla/handlers.(*recoveryHandler).ServeHTTP\n\t:1\nnet/http.serverHandler.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2741\nnet/http.(*conn).serve\n\t/usr/local/go/src/net/http/server.go:1847\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1333”}
Can someone help me please.
My plugin code is:
package main
import (
"fmt"
"io"
"net/http"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/plugin"
)
type HelloWorldPlugin struct {
plugin.MattermostPlugin
}
func (P *HelloWorldPlugin) ServerHttp(c *plugin.Context, w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Hello World!")
}
func (P *HelloWorldPlugin) FileWillBeUploaded(c *plugin.Context, info *model.FileInfo, file io.Reader, output io.Writer) (*model.FileInfo, string) {
flag1 := info.Extension == "jpg"
flag2 := info.Extension == "png"
if flag1 == false && flag2 == false {
s := "server only receiver jpg or png file"
return nil, s
}
return nil, ""
}
func main() {
plugin.ClientMain(&HelloWorldPlugin{})
}
my plugin.json is:
{
"id": "MyMattermostPlugin",
"name": "FileTest",
"server": {
"executable": "plugin"
}
}
I craft the code in Windows10,And I build it like this:
SET CGO_ENABLED=0
SET GOOS=linux
SET GOARCH=amd64
go build -o plugin