GithubHelp home page GithubHelp logo

jenkins-x-plugins / jx-slack Goto Github PK

View Code? Open in Web Editor NEW
11.0 11.0 16.0 1.15 MB

A Jenkins X plugin for receiving Slack notifications about pipeline events

License: Apache License 2.0

Dockerfile 0.73% Go 92.96% Shell 5.67% Mustache 0.64%
hacktoberfest

jx-slack's People

Contributors

aabhas-sao avatar abayer avatar ankitm123 avatar jenkins-x-bot avatar jenkins-x-bot-test avatar jordangoasdoue avatar jstrachan avatar msvticket avatar naik-bharat avatar osamamagdy avatar pow-devops2020 avatar rajatgupta24 avatar rawlingsj avatar tarekas avatar vbehar avatar wowq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jx-slack's Issues

Its unclear how to set MessageFormat flags

The MessageFormat flags don't currently seem to be configurable? Are they supposed to be set via environment variable? If so, should those be built into the deployment template/values?

remove dependency on the jx repo

we are refactoring jx into smaller microservice style CLIs, by doing this we are also moving shared packages into separate repos to with the microservices dependencies.

Currently this repo take a lot of resources to build so lets do the same as above and refactor so we have less heavy weight deps.

WARNING: No pipeline activities exist for org/proj/pr-1000

I just installed the slack bot on a jx3 cluster, but every message is giving the above warning. It is updating messages in the channel, but no review request messages are showing up.

I saw #13 & #14 but as far as I can tell, the labels are there for the pipeline resources

Can be reached in the jenkins-x-user slack at adam_p

jx-boot error when using chart

I'm getting this error from jx-boot: -

error: error validating "config-root/namespaces/jx/slack/slack-slack-deploy.yaml": error validating data: ValidationError(Deployment.spec): missing required field "selector" in io.k8s.api.apps.v1.DeploymentSpec; if you choose to ignore these errors, turn validation off with --validate=false

Using: jx-3 (version: 3.1.73)

401 Bad credentials []

Intermittently seeing these types of errors, wonder if we are not using an authenticated request to github and suffering from lower rate limits, either that or we are calling github too much and we could look at caching details?

WARNING: GET https://api.github.com/repos/jenkins-x-labs/jxl/pulls/83: 401 Bad credentials []

switch from watching slackbots and creating multiple channels that then also watch activities

Right now we list and watch slackbot resources and create a new channel for everyone, then start a new watch of pipeline activities for each. I wonder if instead we change this to use a shared index informer that watches pipeline activities and then have multiple workers, one for each slackbot that is configured? Architecturally this seems like a better fit, will likely be more performant and less overhead I would think.

does not work OOTB with bitbucketcloud

Getting the following error logs:

error: failed to validate options: failed to create SCM client: no username supplied
using driver: bitbucketcloud and serverURL:

The serverURL is missing as well as the username.

Fix: #41

Direct Message Reviewers Feature not working

Installed the latest version of this application to my jx3 cluster, but I am unable to trigger direct messages to requested reviewers

According to the logs it prepares the review request message, but it never sends it.

I do not have a user mapping setup as it was removed from the chart, but I am also not getting any errors that it is unable to find the user.

I used this to set it up

      slack:
        channel: '#jx-pipelines'
        kind: failureOrNextSuccess
        pipeline: all
        notifyReviewers: "true"
        directMessage: "true"

Ideas for expanding Slack app functionality

Overview of some ideas for improving Slack app functionality (most of which are fairly validated by other CI/CD tools)

Rule-based
The Slack app should be rule-based, meaning users can write a more or less unlimited amount of rules to trigger notifications to different channels and in different scenarios. There should be no one global behavior.

Project-based
Users should configure notification rules on a per-project basis so that some projects on the cluster can have different notification rules than other projects.

Branch-based
All rules should have the option to either apply to all branches, to specific branches (via either an explicit string or a regex pattern) or to all branches except (i.e. blacklist some branches)

Triggers
Let users trigger what events send a Slack message, i.e.

  • Only failures or only successes
  • Only on merging vs all PR events vs all commits
  • When new preview environments go live

Personal
The one exception to global rules should be on a per-user basis, where users can configure Slack DMs to be sent to them on their builds if they want. This should default to no and be opt-in, most likely.

Summary Examples

  • For project-microservice-a only notify in #master-builds when builds on the master branch fail
  • For project-experiment-a only notify #team-labs when builds on any branch pass
  • For project-microservice-b notify in #team-channel every time we have a new preview environment

Not getting pipeline messages

I'm trying to setup slack integration on jx3 following this guide. https://jenkins-x.io/v3/develop/ui/slack/#configuring-slack-notifications,

I've already create the slack app and added it to a channel.
image
image

I've also configured slack in source-config.yaml and tried it in multiple levels:

apiVersion: gitops.jenkins-x.io/v1alpha1
kind: SourceConfig
metadata:
  creationTimestamp: null
spec:
  groups:
  - owner: Ibenta
    provider: https://github.com
    providerKind: github
    repositories:
    - name: springboot-template
      slack:
        channel: '#jenkins-x-pipelines'
        kind: all
        pipeline: all
    - name: stencil
      slack:
        channel: '#jenkins-x-pipelines'
        kind: all
        pipeline: all
    scheduler: in-repo
    slack:
      channel: '#jenkins-x-pipelines'
      kind: all
      pipeline: all
  slack:
    channel: '#jenkins-x-pipelines'
    kind: all
    pipeline: all

and the slack pod is already up and running

kubectl get pod -l app=jx-slack
NAME                        READY   STATUS    RESTARTS   AGE
jx-slack-686968776d-dnmtw   1/1     Running   0          3h3m

But i'm still not receiving the notifications. Looking at the logs there's no error. But it did say there's no config for some of my pipelines.

kubectl logs -f jx-slack-686968776d-dnmtw                         
using driver: github and serverURL: https://github.com
wrote git credentials file /root/.git-credentials
about to run: git clone https://github.com/Ibenta/cluster-gitops.git /tmp/jx-git-835694998 in dir /tmp
Cloning into '/tmp/jx-git-835694998'...
about to run: git clone https://github.com/Ibenta/cluster-gitops.git /tmp/jx-git-236991485 in dir /tmp
Cloning into '/tmp/jx-git-236991485'...
W0310 10:16:25.408991       1 warnings.go:70] extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
using the dashboard URL http://dashboard-jx.gitops.ibenta.com
Watching slackbots in namespace jx
Watching pipeline activities in namespace jx and slackbot config 
no slack configuration for ibenta-cluster-gitops-master-3
no slack configuration for ibenta-stencil-head-1
no slack configuration for ibenta-cluster-gitops-master-6
no slack configuration for ibenta-cluster-gitops-master-7

I also don't see any slackbot crds and resources in my cluster as stated in the readme.

kubectl get crd -A | grep jenkins        
environments.jenkins.io                      2021-03-08T12:39:51Z
lighthousejobs.lighthouse.jenkins.io         2021-03-08T12:39:52Z
pipelineactivities.jenkins.io                2021-03-08T12:39:52Z
previews.preview.jenkins.io                  2021-03-08T12:39:52Z
releases.jenkins.io                          2021-03-08T12:39:52Z
sourcerepositories.jenkins.io                2021-03-08T12:39:52Z
k get SlackBot             
error: the server doesn't have a resource type "SlackBot"

Any idea what the issue is? Or any tips to debug this further?

Bug: case mismatch between source-config.yaml and pipeline activity

It seems that pipeline activity is always lower case BUT when owner or repo name is populated into source config it could be mixed case. This causes jx-slack from being able to properly find config and post messages. The workaround is to manually adjust source-config.yaml and make owner/repo lowercase.

I'm not sure if this is a bug for jx-slack or perhaps with how source-config gets populated?

add release pipeline notifications

Current we only seem to be getting slack notifications for Pull Request pipelines. It would also be good to know when a Release pipeline has started, finished but most importantly failed.

add unit test coverage and tests!

When the slack bot was made open source it came with no tests from its original source and so is very hard to make changes, understand what is meant to happen or what may be incorrect.

We should add test coverage and unit / integration tests, at the time of creating this issue we've started to add some but there is a long way to go. Not sure when we can say this issue can be closed, maybe once we get 50% coverage or something?

panic when getting pull request info

with version 0.0.17

after fixing the missing permissions #23 I got the following panic.

It is trying to create a git user, because it failed to retrieve the existing one. for some reason it failed to retrieve the ghOwner at https://github.com/jenkins-x/jx/blob/master/pkg/gits/provider.go#L512
I thought it was a missing permission to read the jx-auth-config configmap, but even after adding this permission it is still failing.

do you have an idea?

thanks

Watching slackbots in namespace jx
Watching pipeline activities in namespace jx and slackbot config test-slack-bot
activity ...
ERROR: logging before flag.Parse: E0326 13:27:57.304913       1 runtime.go:69] Observed a panic: "invalid memory address or nil pointer dereference" (runtime error: invalid
memory address or nil pointer dereference)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x4d4fa7]

goroutine 73 [running]:
k8s.io/apimachinery/pkg/util/runtime.HandleCrash(0x0, 0x0, 0x0)
        /go/pkg/mod/k8s.io/[email protected]/pkg/util/runtime/runtime.go:58 +0x105
panic(0x23d69e0, 0x4977650)
        /usr/local/go/src/runtime/panic.go:522 +0x1b5
fmt.Fprintf(0x0, 0x0, 0x277ef5f, 0x5, 0xc0016a8ed0, 0x1, 0x1, 0x40c148, 0xc0, 0x288af90)
        /usr/local/go/src/fmt/print.go:200 +0x77
gopkg.in/AlecAivazis/survey.v1/terminal.(*Cursor).HorizontalAbsolute(...)
        /go/pkg/mod/gopkg.in/!alec!aivazis/[email protected]/terminal/cursor.go:54
gopkg.in/AlecAivazis/survey.v1/core.(*Renderer).resetPrompt(0xc000293b90, 0x0)
        /go/pkg/mod/gopkg.in/!alec!aivazis/[email protected]/core/renderer.go:59 +0x12c
gopkg.in/AlecAivazis/survey.v1/core.(*Renderer).Render(0xc000293b90, 0x285344a, 0x1f0, 0x25a2d80, 0xc00122cd80, 0x0, 0xc0001f2a40)
        /go/pkg/mod/gopkg.in/!alec!aivazis/[email protected]/core/renderer.go:69 +0x3b
gopkg.in/AlecAivazis/survey%2ev1.(*Input).Prompt(0xc000293b90, 0x0, 0x0, 0x0, 0x0)
        /go/pkg/mod/gopkg.in/!alec!aivazis/[email protected]/input.go:44 +0xe9
gopkg.in/AlecAivazis/survey%2ev1.Ask(0xc0016a9280, 0x1, 0x1, 0x22491a0, 0xc00090e3e0, 0xc0016a92f0, 0x1, 0x1, 0x10b65c1, 0x2576d00)
        /go/pkg/mod/gopkg.in/!alec!aivazis/[email protected]/survey.go:148 +0x187
gopkg.in/AlecAivazis/survey%2ev1.AskOne(0x3192600, 0xc000293b90, 0x22491a0, 0xc00090e3e0, 0x2889770, 0xc0016a92f0, 0x1, 0x1, 0xc0016a9318, 0x2)
        /go/pkg/mod/gopkg.in/!alec!aivazis/[email protected]/survey.go:94 +0xcd
github.com/jenkins-x/jx/pkg/util.PickValue(0xc001305920, 0x14, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /go/pkg/mod/github.com/jenkins-x/[email protected]/pkg/util/pickers.go:25 +0x192
github.com/jenkins-x/jx/pkg/auth.(*AuthConfig).EditUserAuth(0xc001797500, 0xc001233248, 0xa, 0xc001252aa0, 0x0, 0x0, 0x0, 0xc001252af0, 0x0, 0x0, ...)
        /go/pkg/mod/github.com/jenkins-x/[email protected]/pkg/auth/auth_config.go:352 +0x2d1
github.com/jenkins-x/jx/pkg/gits.createUserForServer(0x25e1100, 0xc001252aa0, 0x31c5c00, 0xc0016dec60, 0xc001797620, 0x32377e0, 0xc00186ea78, 0x0, 0x0, 0x0, ...)
        /go/pkg/mod/github.com/jenkins-x/[email protected]/pkg/gits/provider.go:543 +0x151
github.com/jenkins-x/jx/pkg/gits.CreateProviderForURL(0x2376401, 0x31c5c00, 0xc0016dec60, 0x2780ae7, 0x6, 0xc001233240, 0x12, 0x0, 0x0, 0x32377e0, ...)
        /go/pkg/mod/github.com/jenkins-x/[email protected]/pkg/gits/provider.go:523 +0x583
github.com/jenkins-x/jx/pkg/cmd/opts.(*CommonOptions).GitProviderForGitServerURL(0xc00031b500, 0xc001233240, 0x12, 0x2780ae7, 0x6, 0x0, 0x0, 0x20bd00b, 0xc0014ee803, 0x4, ...)
        /go/pkg/mod/github.com/jenkins-x/[email protected]/pkg/cmd/opts/git.go:269 +0x25e
github.com/jenkins-x/jx/pkg/cmd/opts.(*CommonOptions).CreateGitProviderForURLWithoutKind(0xc00031b500, 0xc00061a800, 0x32, 0x0, 0xc000a85848, 0x40c148, 0x60, 0x260c860)
        /go/pkg/mod/github.com/jenkins-x/[email protected]/pkg/cmd/opts/git.go:287 +0x178
github.com/jenkins-x-labs/slack/pkg/slackbot.(*SlackBotOptions).getPullRequest(0xc0002597a0, 0xc0013471d0, 0xb, 0xc00005e501, 0xc00005e500, 0xc000a85918)
        /workspace/source/pkg/slackbot/bot.go:686 +0x19e
github.com/jenkins-x-labs/slack/pkg/slackbot.(*SlackBotOptions).isEnabled(0xc0002597a0, 0xc0013471d0, 0xc0003afa10, 0x1, 0x1, 0x0, 0x0, 0x0, 0xc000a85a80, 0x18, ...)
        /workspace/source/pkg/slackbot/bot.go:132 +0xff
github.com/jenkins-x-labs/slack/pkg/slackbot.(*SlackBotOptions).PipelineMessage(0xc0002597a0, 0xc0013471d0, 0x278b5e4, 0xc)
        /workspace/source/pkg/slackbot/bot.go:161 +0x180
github.com/jenkins-x-labs/slack/pkg/slackbot.(*SlackBotOptions).onObj(0xc0002597a0, 0x2732ce0, 0xc0013471d0)
        /workspace/source/pkg/slackbot/activity.go:49 +0x110
k8s.io/client-go/tools/cache.ResourceEventHandlerFuncs.OnAdd(...)
        /go/pkg/mod/k8s.io/[email protected]/tools/cache/controller.go:195
k8s.io/client-go/tools/cache.(*processorListener).run.func1.1(0x0, 0x0, 0x0)
        /go/pkg/mod/k8s.io/[email protected]/tools/cache/shared_informer.go:554 +0x26d
k8s.io/apimachinery/pkg/util/wait.ExponentialBackoff(0x989680, 0x3ff0000000000000, 0x3fb999999999999a, 0x5, 0xc0016a9e38, 0x42b6af, 0xc0000e8940)
        /go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:203 +0xde
k8s.io/client-go/tools/cache.(*processorListener).run.func1()
        /go/pkg/mod/k8s.io/[email protected]/tools/cache/shared_informer.go:548 +0x89
k8s.io/apimachinery/pkg/util/wait.JitterUntil.func1(0xc000a5cf68)
        /go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:133 +0x54
k8s.io/apimachinery/pkg/util/wait.JitterUntil(0xc0016a9f68, 0xdf8475800, 0x0, 0x42bf01, 0xc0000ba600)
        /go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:134 +0xf8
k8s.io/apimachinery/pkg/util/wait.Until(...)
        /go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:88
k8s.io/client-go/tools/cache.(*processorListener).run(0xc000a33a00)
        /go/pkg/mod/k8s.io/[email protected]/tools/cache/shared_informer.go:546 +0x9c
k8s.io/apimachinery/pkg/util/wait.(*Group).Start.func1(0xc000316370, 0xc000092080)
        /go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:71 +0x4f
created by k8s.io/apimachinery/pkg/util/wait.(*Group).Start
        /go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:69 +0x62

deploy chart version 0.0.65

It seems like the latest release has not yet been pushed to the Helm repo:

$ helm search repo jxgh | grep jx-slack
jxgh/jx-slack                           0.0.64          0.0.64          A Slack bot for Jenkins X

Edit:
Nevermind, forgot to update the repository...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.