mirror of
https://github.com/appleboy/drone-jenkins.git
synced 2026-06-04 18:23:57 +08:00
@@ -0,0 +1,72 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/telegram-bot-api.v4"
|
||||
)
|
||||
|
||||
type (
|
||||
// Repo information.
|
||||
Repo struct {
|
||||
Owner string
|
||||
Name string
|
||||
}
|
||||
|
||||
// Build information.
|
||||
Build struct {
|
||||
Event string
|
||||
Number int
|
||||
Commit string
|
||||
Message string
|
||||
Branch string
|
||||
Author string
|
||||
Status string
|
||||
Link string
|
||||
}
|
||||
|
||||
// Config for the plugin.
|
||||
Config struct {
|
||||
URL string
|
||||
Token string
|
||||
Job []string
|
||||
}
|
||||
|
||||
// Plugin values.
|
||||
Plugin struct {
|
||||
Repo Repo
|
||||
Build Build
|
||||
Config Config
|
||||
}
|
||||
)
|
||||
|
||||
func trimElement(keys []string) []string {
|
||||
var newKeys []string
|
||||
|
||||
for _, value := range keys {
|
||||
value = strings.Trim(value, " ")
|
||||
if len(value) == 0 {
|
||||
continue
|
||||
}
|
||||
newKeys = append(newKeys, value)
|
||||
}
|
||||
|
||||
return newKeys
|
||||
}
|
||||
|
||||
// Exec executes the plugin.
|
||||
func (p Plugin) Exec() error {
|
||||
|
||||
if len(p.Config.Token) == 0 || len(p.Config.To) == 0 {
|
||||
log.Println("missing jenkins auth config")
|
||||
|
||||
return errors.New("missing jenkins auth config")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user