jenkins-x-plugins / jx-updatebot Goto Github PK
View Code? Open in Web Editor NEWa simple plugin to create downstream pull requests as part of your release pipeline
License: Apache License 2.0
a simple plugin to create downstream pull requests as part of your release pipeline
License: Apache License 2.0
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
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
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
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
.
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?
e.g. so we can configure go mod tidy
or make build test
or something after changing, say, a go.mod
like this example https://github.com/jenkins-x/go-scm/blob/main/.jx/updatebot.yaml#L8
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.