GithubHelp home page GithubHelp logo

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

View Code? Open in Web Editor NEW
10.0 10.0 15.0 1.27 MB

a simple plugin to create downstream pull requests as part of your release pipeline

License: Apache License 2.0

Dockerfile 0.18% Makefile 4.85% Go 85.42% Shell 7.40% Smarty 2.16%
hacktoberfest

jx-updatebot's People

Contributors

ankitm123 avatar dependabot[bot] avatar haysclark avatar igdianov avatar jenkins-x-bot avatar jenkins-x-bot-test avatar jstrachan avatar juneezee avatar mattpodraza avatar msvticket avatar osamamagdy avatar pow-devops2020 avatar rawlingsj avatar sudiptob2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jx-updatebot's Issues

support creating PRs on all `SourceRepository` resources

rather than listing every git repository explicitly in the .jx/updatebot.yaml file it might be nice to be able to specify some kind of pattern match of all the SourceRepository resources for all the repos that are imported into Jenkins X.

e.g. if you have 10 repos imported into Jenkins X and you are releasing a new library/binary/thing and want to PR all your other 9 repos to upgrade to use it you might just want to specify a rule for which SourceRepository repos to upgrade (if they match the regex/files).

e.g. instead of...

apiVersion: updatebot.jenkins-x.io/v1alpha1
kind: UpdateConfig
spec:
  rules:
    - urls:
        - https://github.com/myorg/repo1
...
        - https://github.com/myorg/repoN
      changes:
        - regex:
            pattern: "FROM\\s+image: gcr.io/myorg/something:(.*)"
            files:
              - "Dockerfile*"

it might be nice to have a rule to match all repos (but the current repo)...

apiVersion: updatebot.jenkins-x.io/v1alpha1
kind: UpdateConfig
spec:
  rules:
    - repositories:
        includes: 
          - myorg/*
        excludes:
          - *docs  
      changes:
        - regex:
            pattern: "FROM\\s+image: gcr.io/myorg/something:(.*)"
            files:
              - "Dockerfile*"

by adding to the Rule struct something like...

// Rule specifies a set of repositories and changes
type Rule struct {James Strachan, 30 days ago: • fix: initial spike
	// URLs the git URLs of the repositories to create a Pull Request on
	URLs []string `json:"urls"`

        // Repositories provides a filter of repositories to find (via the `SourceRepository` CRDs)
        Repositories *RepositoryFilter

	// Changes the changes to perform on the repositories
	Changes []Change `json:"changes"`
}
....
if rule.Repositories != nil {
	srList, err := jxClient.JenkinsV1().SourceRepositories(ns).List(context.TODO(), metav1.ListOptions{})
	if err != nil {
		return errors.Wrapf(err, "failed to find any SourceRepositories in namespace %s", ns)
	}
        // lets add the URLs of all the matching SourceRepository resources...
         for _, sr := range srList.Items {
           if rule.Repositories.Matches(&sr) {
              rule.URLs = append(rule.URLs, sr.Spec.URL)
           }
       }
}

then we can use include/exclude patterns on the repository owner/repo strings to find which SourceRepository's to process etc

support helm chart upgrades OOTB

with the old jx step create pullrequest chart we baked in the knowledge of how to upgrade a helm version change in source code.

it might be nice to add helm as a change option in the .jx/updatebot.yaml file format so folks could upgrade helm charts without worrying about the files to match + the regex stuff.

e.g. here's the code...
https://github.com/jenkins-x/jx/blob/master/pkg/cmd/step/create/pr/step_create_pr_chart.go#L94

so we could maybe enhance the config file: https://github.com/jenkins-x/jx-cli/blob/master/.jx/updatebot.yaml

to allow

apiVersion: updatebot.jenkins-x.io/v1alpha1
kind: UpdateConfig
spec:
  rules:
    - urls:
        - https://github.com/jenkins-x/jxr-versions
      changes:
        - chart: 
            name: my-chart

Working directory of image is set

This makes tekton not set the directory, meaning that the workingDir setting in the pipeline won't be in effect. This might be surprising...

Example step:

        - image: ghcr.io/jenkins-x/jx-updatebot:0.1.3
          name: promote
          workingDir: /workspace/source
          script: |
            #!/usr/bin/env sh
            source .jx/variables.sh
            jx updatebot pr --pull-request-title "chore(deps): upgrade myapp to version $VERSION" --auto-merge=false

This gives the log

/tekton/scripts/script-9-kzhm6: 2: /tekton/scripts/script-9-kzhm6: source: not found
found file /tmp/jx-git-861085259/helmfiles/jx-production/helmfile.yaml
modified file /tmp/jx-git-861085259/helmfiles/jx-production/helmfile.yaml
Created Pull Request: https://github.com/redacted/jx3-cluster-production/pull/171

The effect is that the title of the PR becomes just: chore(deps): upgrade myapp to version

Parameter `--pull-request-body` don't pass content to Pull Requests

According to the documentation there is a parameter --pull-request-body to insert a PR body using jx-updatebot pr command. I looked at the code and it requires both --pull-request-body and --commit-message (not empty) to be able to display body in Pull Request, but in fact, the content of --commit-message is passed to the PR body instead of content of --pull-request-body.

GitHub Enterprise seems to be (accidentially?) not supported

I have tried JX Updatebot 0.1.1 to create an updating PR, see https://github.com/opajonk/test_a and https://github.com/opajonk/test_b (b "depends on" a, and a contains a configuration to update b). The following command was used:

jx-updatebot pr --version 0.2.0 --auto-merge false --git-kind github --git-server https://github.com --git-username opajonk --git-token token

This worked as expected.

The exact same thing did not work when trying to use it on a GitHub Enterprise instance:

jx-updatebot pr --version 0.2.0 --auto-merge false --git-kind github --git-server https://github.enterprise.instance --git-username user --git-token token

The output is:

error: failed to create Pull Request on repository https://github.enterprise.instance/user/test_b.git: failed to create ScmClient: failed to create SCM client for https://github.enterprise.instance/user/test_b.git: failed to discover the git kind for git server https://github.enterprise.instance: failed to list SourceRepository resources in namespace default: the server could not find the requested resource (get sourcerepositories.jenkins.io)

(I had to redact the URLs / users / tokens, but other than that this is the exact message)

For me this hints to an (unexpected?) tie to public GitHub?

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.