rebuild previous build for a jenkins job manually - jenkins

I could click Build Now to build a jenkins job again if the job is corresponded to a specific branch.
What if the job is related with multiple branches? That is, I utilized wildcard branch specifier.
When I click Build Now, it will rebuild the last build. I'm wondering if there is a way to rebuild those previous builds.

Yes you can rebuild any build with his own parameter.
1. Install rebuild plugin.
2. select the build that you want to rebuild and press rebuild.
enter image description here

Related

Prevent added artifact to Release on Gated build

In order to save on the maintenance of build definition I create one build for Gated & Publish.
I also create a release that triger when my build run as deploy (As described in the link)
When build run as deploy (not Gated) there are another tasks that run during the build:
Publish Build Artifacts - upload artifacts
Update Build Name - change the build name to "Auditing [Version]" format
Add build tag - Use to triger release
When I am try to create release manuly I get list of artifacts, some of the artifact are resualt of gated build.
In the image bellow I market the gated build.
I'm interested in keeping a clean list, is there a way to prevent from tfs to add gated build to my articact list
I am working with TFS 2018.2 On-Prem.
Thanks In advance for all.

Deploy promoted builds in Jenkins

I have two Jenkins tasks, one that builds and promotes the successful build, and another task that deploys those promoted builds. I'm using two plugins to accomplish this task, Copy Artifact Plugin and promoted builds.
The job that I have to build the code is a very standard one, I go to the git repository every minute to check for any changes, and if there are any changes I just Invoque Gradle Script on the Build step and select Use Gradle Wrapper box and everything builds without a problem. The only custom part of this build task is that I'm using promoted builds plugin, which works great and have a very standard configuration as well.
Build Configuration
I'm happy with my Build task, but I have a problem with my Deploy task. In my deploy task I want to select which promoted build I want to deploy, but I can't deploy the selected promoted build.
In my Deploy task I tick the This project is parameterised box and I selected the Promoted Build Parameter.
Promoted Build Parameter Configuration
The configuration looks ok, when I run the Deploy task I can select which build I want to deploy.
Select build to be deployed
The problem that I have is when I select Copy artifacts from another project. In Which build I select Specified by a build parameter and for the Parameter Name I selected the same name I gave to the Promoted Build Parameter
Copy artifacts from another project Configuration
But when I run this Deploy task I get this error: ERROR: Unable to find a build for artifact copy from: Aurora.
BUT if I change the Which build part to Copy from WORKSPACE of latest completed build everything works fine.
Working Configuration
What am I doing wrong in this configuration?
I was able to solve this problem, I don't think it was the cleanest way of doing it but at the end it worked. In the Build task I left everything as it was, I only added a Post-Build Action to Archive the artifacts.
Post Build Action
In the Deploy task I needed to change a bit more stuff. In my Deploy task I tick the This project is parameterised box and I selected the Promoted Build Parameter, the configuration for this step is a very standard one, I just selected the Build project and the rest is automatic. This step enables me to select which promoted build I want to deploy, but this is where the big problem resides. The value that this "step" returns is something like this https://site.name.com/job/ProjectName/137/.
The problem that this create is in Copy artifacts from another project. I need a build number, but I only have that URL, so the solution that I found was to get the build number from that URL, inject that number as a local variable and use that local variable in the next steps.
Build steps
With this solution I'm able to deploy only the promoted build.

Prevent Release Trigger on Gated Check-in build

How to stop the release trigger on Gated check-in build which doesn;t produce any artifact?
I have a build definition with Gated check-in enabled. In Publish and Publish Artifact Steps I have set the condition as following:
ne(variables['Build.Reason'],'CheckInShelveset')
which means - if the build was triggered by Gated check-in, do not run this step.
I do not see any files in drop folder of this build run but the release is being triggered as soon the gated build completes running.
I've added images for reference purposes.
Image 1 shows the configuration of build definition.
Image 2 shows the "publish" steps are not running as it's a gated build.
Image 3 shows the release being triggered from the same build even when there is nothing in drop (output) folder!
This is very surprising to me. Any help?
Thanks!
There is an option on the first environment where you can set an Artifact filter, enter Include TriggerRelease:
By tagging your build (in case it's not a gated check-in), you can prevent the release from triggering. You can run a small magic log command to set the tag in the build:
Write-Host "##vso[build.addbuildtag]TriggerRelease"
Or you can use a build task from the following extension to have a build tag itself:

How do I re-run a build?

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.

Archiving artifacts in Jenkins and choosing which artifact to deploy to environment

I have curren Jenkins jobs:
1. Poll -- Retrieve Latest Tag from SVN
2. Create release and archive it
3. Manual trigger -- Deploy artifact to test environment
So 1. retrieves regularly the latest SVN tag (if created), 2. builds the release (.ear files and DB scripts) and stores the artifacts with the "Archive the artifacts" post-build job, and 3. is a manual trigger job where you actually would have to press a button to deploy the release to test environment
My question is, is it possible in build 3. to somehow "select" the desired artifact? Or is it only possible to deploy the latest workspace? Thanks!
Here is a detailed explanation how to select a specific build for deployment
How to promote a specific build number from another job in Jenkins?
In short, you need to combine Copy Artifacts plugin with Promotions concept

Resources