I am using the "inverse" build strategy. When we do a merge from feature branch to development branch, then from development branch to release branch. We can see Jenkins did see the changes in the branch, but started only one build. It's not starting the build for origin/REL-Sprint1606. There is line shows Label=[origin/REL-Sprint1606]
Checking out Revision b81dd73053889e753b41565a4ecec99c081eb1b0 (origin/development, origin/REL-Sprint1606)
Regular expression run condition: Expression=[.*\/[dD][eE][vV].*], Label=[origin/development ]
I found this bug report to Jenkins, but it's closed now:
Git plugin only triggers a build for one branch
https://issues.jenkins-ci.org/browse/JENKINS-11337
Related
I have some old release branches in git: release/2022.1, release/2022.2, release/2022.3.. I have some old ones for the previous years as well.
Now starting from branch release/2022.4 and for the following years from now on, I would like to trigger my Jenkins build job when that branch is created from master (it will not be modified).
The issue: when I do the configuration of the Jenkins it automatically triggers job for all my previous release branches which is NOT what I want. How to tell Jenkins "start from now on" for every new release branch?
Configuration:
Discover branches:
Exclude branches that are also filed as PRs
Discover pull requests from origin:
Merging the pull request with the current target branch revision
Filter by name (with wildcards):
Include:
release/*
Thanks a lot!!!
We use the gitflow branch strategy to maintain our repositories. This is linked to a multibranch pipeline in jenkins. That all works just fine.
Im wondering if it's possible to prevent building the master branch if another branch, let's say develop, has failed.
Usually we merge all code into develop, then into master for deploy. So if develop is failing, we'd prefer not to build and deploy master.
Instead of preventing a build on master, you shouldn't be merging. Only merge to master if your build on develop was successful and passed all tests.
Even when it comes the the merge - you can merge in a new 'merge branch' (taken from master) and deal with any conflicts/issues, test the build on that, and only if that succeeds does the actual merge to master take place.
Hope this helps.
All our Jenkins jobs are configured to build changes on all branches in a repository. There are times where we want to re-run a specific build that ran against a specific commit.
a build fails because some external resource was unavailable and we want to re-run that commit once the resource is up again;
a job depends on an internal package and we need to be able to re-build specific branches to pick up the latest version of that package.
Jenkins' "Build Now" command, however, builds on the branch of the last build. It doesn't let the user choose what branch to build on. In order to rebuild a branch, users have to commit and push a change to that branch.
Is there a plugin that will allow the user to re-run a specific build or choose the branch to build on? If you've used TeamCity, I want the "Re-run with same revisions" feature.
We've tried both the Naginator and Rebuilder plugins. Naginator only lets you rebuild failed builds, but also automatically re-builds failed builds at least once (not desireable). Rebuilder always rebuilds the last commit. It behaves just like the "Build Now" button.
The Rebuild plugin is probably the closest plugin to what you want however as you have found it only will get HEAD and not a specific git revision.
This is an open feature request.
The comment on this question notes the same thing.
All that being so I would still suggest that you should perhaps reconsider the idea of depending on the git revision to drive the outcome of your build. You should want to build the HEAD.
Since I'm using Gitflow all my branches include a slash. Like "feature/awesome-feature".
When I try to tell Jenkins to build this branch it throws an error "ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job."
Is it possible to use "/" in branch names at all? The issue was reported/fixed/unfixed numerous times. So I'm not sure about the current state.
Yes I build branches like this all the time and it works just fine.
Set your branch as "refs/heads/feature/awesome-feature"
Which version of jenkins are you on?
I'm on 1.580.3
Do you have any commits yet? If your repo is empty, it would have no HEAD, and therefore no branch, as in this question: While building a git project from jenkins it shows an error like couldn't find any revision to build
In Jenkins, I have a "Build" job setup to poll my git repo and automatically build on change. Then, I have separate "Deploy to DEV", "Deploy to QA", etc. jobs that will call an Ant build that deploys appropriately. Currently, this configuration works great.
However, this process favors deploying the latest build on the latest development branch. I use the Copy Artifact plugin to allow the user to choose which build to deploy. Also, the Ant scripts for build/deploy are part of the repo and are subject to change. This means it's possible the artifact could be incompatible between versions. So, it's ideal that I ensure that the build and deploy jobs are run using the same git checkout.
Is there an easier way? It ought to be possible for the Deploy job to obtain the git checkout hash used from the selected build and checkout. However, I don't see any options or plugins that do this.
Any ideas on how to simplify this configuration?
You can use Parameterized Trigger Plugin to do this for you. The straight way is to prepare file with parameters as a build step and pass this parameters to the downstream job using the plugin. You can pass git revision as a parameter for example or other settings.
The details would vary for a Git repo (see https://stackoverflow.com/a/13117975/466874), but for our SVN-based jobs, what we do is have the build job (re)create an SVN tag (with a static name like "LatestSuccessfulBuild") at successful completion, and then we configure the deployment jobs to use that tag as their repo URL rather than the trunk location. This ensures that deployments are always of whatever revision was successfully built by the build job (meaning all unit tests passed, etc.) rather than allowing newer trunk commits to sneak into the deployment build.