Can I configure a Plan Trigger to run a dynamic branch daily? - bamboo

Problem
Bamboo runs daily integration tests on integration environment. When the bamboo branch is different to integration test environment these tests tend to fail partially. (any new tests in newer branch fail)
What I'm trying to do to solve this?
Use bamboo Command to get the current branch deployed on integration
Use that value somehow to tell bamboo to trigger that specific branch on the current run
Any idea on how I tell bamboo to run the plan on the specified branch?

You can use REST call to add build into queue,
/queue/{projectKey}-{buildKey}?stage&executeAllStages&customRevision
https://docs.atlassian.com/bamboo/REST/5.13.1/#d2e413

Related

GitLabCI deploy to one of x environments

We have a pretty big CI Pipeline including E2E Tests. We currently cannot use the GitLab feature of deploying to dynamic environments, because there is currently still manual work necessary for creating an environment. Therefore all e2e tests run against a single "E2E stage". I would like to add more E2E stages manually.
But here is the problem:
How can I deploy to one (currently unused) E2E stage, run the tests (in a different GitLabCI job) and lock the stage for other tests during that time?
I tried using three special runners with different tags ( ["e2e", "e2e-1"], ["e2e", "e2e-2"], ["e2e", "e2e-3"] ), but I could not tell GitLab to run all jobs of a pipeline on one of these runners (chosen randomly or even better which one is currently free) only. If I start the deployment on "e2e-3" and after that "e2e-1" is free for testing, it might choose that one, which then will not have the correct artifact deployed.

Bamboo scripted buildplans

We are currently using bamboo to build and test our software. Now our build plans are just a bunch of task: execute this bat, execute that bat etc. Created with the Bamboo UI.
It happens that over months/years the build plan needs adjustments:
Parallelize jobs
Add extra jobs
Change some tasks
But this will break when we try to build an older version of the software. Some scripts (called from bamboo task) are not-existing in older versions.
At my previous employer we used Jenkins pipelines where the content of the build and test was just a file present in the sources repo.
Now with bamboo it appears you can use Bamboo Specs. From I read you create specs file and when you run this, it which will create build plan. But I don't see a relation to cater for changing build plans over time (changing steps).
For example the Bamboo Specs of develop are used to build all Plan Branches (e.g. Pull Requests). So if you want to change the build in a PullRequest, you first need to merge this into develop, the Bamboo Spec of develop updates the Build Plan. Not possible to test this before merging.
Question: How can you make scripted buildplans in Bamboo, where every branch of develop can a have possible other way of building?
We have it now setup as:
Buildplan 'Product A': plan branches: develop, release_x, release, y
Buildplan 'Product A PullRequest': plan branches: feature/*
Edit: supported in 7.0: https://confluence.atlassian.com/bamboo/enhanced-plan-branch-configuration-996709304.html
Old answer:
I found Atlassian documentation: https://jira.atlassian.com/browse/BAM-19620. They call it 'divergent plan branches'. No support, there is a feature request.
As of 15-4-2019:
Atlassian Update – [11 April 2019] Hi everyone,
Thank you for your votes and thoughts on this issue.
We fully understand that many of you are dependent on this
functionality.
After careful consideration, we've decided to prioritise [this
feature] on Bamboo roadmap. We hope to start development after our
current projects are completed.
Expect to hear an update on our progress within the next 6 months.
To learn more on how your suggestions are reviewed, see our updated
workflow for server feature suggestions.
Kind regards,
Bamboo Team
Question: How can you make scripted build plans in Bamboo?
To make scripted build plans in Bamboo, you have to use bamboo specs. Since you are already familiar with Jenkins, bamboo specs work exactly like Jenkinsfile by automating your pipeline. The benefit of using this is that it lives in your source code and the changes you make to this file in your source code automatically changes your plan(pipeline) when bamboo build is triggered.
This is how I script build plans in bamboo:
I add my bamboo.yml file under the root of my repo. But currently, I use git subtree and my bamboo specs live in there. But you don't have to do this. The below link provides you with a simple approach.
Link my repo to bamboo
Tell bamboo to scan for bamboo specs in the repo
Make commit and push
https://confluence.atlassian.com/bamboo/tutorial-bamboo-specs-yaml-stored-in-bitbucket-server-941616819.html
If I have to make changes to the plan in the future, I edit the bamboo specs file then commit and push.
I had the same problem and unfortunately had to go through an unpleasant choice
Backporting the build script
This is not necessarily feasible everywhere, but I managed to make it work somehow for my project.
The idea is: treat the build script as a C#/Java interface, or better as a contract.
As soon as your branches do not provide significant changes in building the software, e.g. your desktop app becomes a web app, or you switch from Ant to Gradle, you can handle this.
Assuming my application is always a web application to be released as a jar on JFrog Artifactory, I have identified the following steps that are common to all maintained versions:
Use javac to build the jar of all modules
Use gulp to build the Javascript resources
Run JUnit from the repository
Baptize 💒 the artifacts with a version number obtained with a tricky algorithm
Push the artifacts to JFrog Artifactory
So the idea is that I had taken my Ant build script and mostly rewrote it in order to do the same tasks on different versions of the application. I started doing the changes from an older version, not maintained anymore, as an excercise. In fact, my official Git branches look like release/x.y.z where semver is x.y.z.k and newer bugfix-builds are built from the head of any x.y.z release.
So I took release/3.10.0 branch and rewrote Ant. I am currently testing with a manually created Bamboo plan
Stage: Compile
ant clean ivy-retrieve compile jar #builds the jar in a job
ant gulp-install gulp-prod zip #creates javascript resources
Stage: Test
ant run-junit
Manual Stage: Release
ant baptize ivy-release #tags the artifact using ${bamboo.jira.version} and pushes to JFrog Artifactory
What I am going to do with Yaml
Since the build script is the same, but specific tasks (e.g. Java compiler version) may change in different versions, I can create a very single Yaml script that rules them versions all.
I will then merge release/3.10.0 => release/3.10.1 => release/3.10.2 ... release/3.11.2 by merging the conflicts
Personal experience
Tonight I am struggling in making the JUnit tests work as I also chose to backport my testing framework to the older version of the project. I accept that a few tests will fail because older and non-maintained versions contain bugs. For me this is a way to prove that the system works.
Indeed, diverging branches are a great idea, but I am forced to use Bamboo 6 in my office

Bamboo build with local and remote agents

I have a .Net WebApi project and continuous integration is setup using Bamboo. I am using spec flow tests and some of the tests are tagged to run on bamboo remote agent as they are slow in nature. Other tests supposed to be run on multiple local agents. I have setup multiple stages in Bamboo build plan as stages get run in parallel with each stage is set to run specifically tagged tests suits.
My question is what is the general practice to setup a Bamboo plan to run on multiple agents (local and remote) and how can I share one MS Build output (dlls and config) across multiple agents.
If you need to split build and test phase then usually you have Build stage with one job which produces artifact with build output.
Then you create another stage and put several jobs there. Jobs may be configured to download produced artifact from Build stage and execute tests against your build.
If you want to run some of your jobs at remote agent, you can add some Job requirement which only remote agent can satisfy.

Triggering Jenkins after TFS build

I was wondering if it is possible for Jenkins to be notified after TFS finishes a build.
I'm trying to make a system where, after the TFS build, Jenkins is used to run automated selenium tests.
Thanks in advance!
You have a few options:
You could use a GenericTest to trigger Jenkins and include as part of the Build Definition. This also allows your script to communicate pass/fail information back to the build.
You could just include an InvokeProcess workflow activity to trigger Jenkins. The process would be similar to this or this.
Or you could use a tool that would trigger after a Team Build has finished. Normally people would use tools that then deploy stuff. Most of these tools trigger a Powershell script at some point, which would allow you to trigger the test run:
Octopus Deploy
TFS Deployer

Update Hudson build result status after external tests

We use Hudson for our build/CI needs. In addition to unit tests (running during build) I have a staging environment that runs additional integration tests. Basically the build happens and then build artifacts are submitted the external system. I do not wish to block a Hudson build to wait for integration tests (as that locks the station into idle, and prevents it from building anything else). What I want is to update the the result of the build with the result of the external tests (and attach some logs back to the build, if possible).
Now because the staging environment is asynchronous to the build system (i.e. other systems/people can submit tests), Hudson can't be just monitoring what goes on there right after the build. Hudson build just goes into a test queue. So, I need to notify Hudson, it can't be polling something for updates.
Does Hudson support such behaviour, and if so, how can I achieve it?
I would suggest using the hudson users mailing list [1]
[1] http://java.net/projects/hudson/lists/users/archive
To solve the asynchronous wait issue, you can use the build triggering with an authentication token, and use it in a script.
The Build Triggers section has a Trigger Builds Remotely (e.g. from scripts), which when selected allows you to enter an Authentication Token (which has the descriptive text from your question).
You can thus, remotely trigger the build from a script, i.e., have it as part of the integration test script and trigger the build job using this authentication token.
..
You can have a downstream project just for result collection that integrates the results from various tests and report it to the master and aggregate them all. This project can be triggered using the authentication token, or if there is a single integration test job, you can tie it up as a downstream project.