Template Build and Deployment for Bamboo

Description

Template your build and deployment tasks, artifact definitions or variables. 

Support build and deployment task templating and a variety of security features:

  • Define which plans should be considered as templates;
  • Define which plans will use the template;
  • User interactions designed to block unauthorized access to job configurations;
  • Support build/environment task replication but also miscellaneous plugin configuration, artifact definitions or job requirements;


Usage steps for build projects:

  1. Designate your plans that are templates by going on the plan Miscellaneous configuration page and ticking "Is template".
  2. Go on a Job Miscellaneous configuration page in a different plan.
  3. Under the section Template list you should see now the jobs of the plan which was marked as template.
  4. Tick what do you want to sync:

  • Template Tasks Definition
  • Template Artifact Definition
  • Attempt to maintain task states
  • Merge Job Requirements
  • Click Save and your replication will start !

  • Merge Job Misc Configuration
Usage steps for deployment environments:
  1. Designate your environment templates by creating a variable named IS_TEMPLATE with value Yes.
  2. Create in the secondary environment a variable named LINKED_TEMPLATE_ID and enter the id of the target environment (is a number like 88408073 or <Project name>/<Environment name>). 
  3. Go to the system settings page and trigger the replication from the Ad-dons Menu -> Template Replication.
A note only, replication will not sync only the current job, but all jobs, in all plans that have a template. How is this impacting ? When you do a change to the tasks of a template, go on the Miscellaneous configuration page of the template and click save so that all your plans get updated with the new task definition.

Security Feature

Under administration of bamboo the Templating engine has a security setup. From here you can control who can see the operations menu entry or to prevent accidental variable / permissions replications



Also if an environment has the variable BLOCK_PERMISSION_REPLICATION or the variable BLOCK_VARIABLE_OVERWRITING you can also block the permission/variables replications.

Reporting and UI

The plugin has also a simple control center allowing you to see reports regarding templates used, trigger replication of templates or bulk configuration of templates


As some of these operations could be quite dangerous for your build system this can be restricted to administrators from the main security page:






34 comments:

  1. Anonymous8/16/2016

    Hello,
    i am just evaluating your plugin for our deployment process. One thin i noticed is, that the task "Download artifacts" is not replicated correctly if i edit the definition (i.e. add more artifact downloads to the same task). Is this intended?
    Greets
    Sascha Grau

    ReplyDelete
  2. Hi Sasha,

    this is intended, I am not touching checkout and download artifacts type of tasks as they usually are used as a specific thing within the build.

    I can make it configurable if you like.

    Julius

    ReplyDelete
    Replies
    1. Anonymous7/20/2017

      That would be great, because now we have to delete all checkout and artifact download definitions before we replicate the plans.

      Kind regards
      Sascha Grau

      Delete
  3. Hi,
    I am evaluating that plugin, and I am wondering if "Plan variables" and "Deploy environment variables" are managed through that plugin?
    Even if that feature is mentioned in the description, I was not able to figure out how malling it works.

    In addition, do you have a more detailed documentation?

    Regards,
    Philippe.

    ReplyDelete
    Replies
    1. Hi,

      the plugin is handling variables for deployment projects at the moment, by attempting to create any variables not existing on the environment but existing on the template.

      We can try to do same if you need for regular build plans.

      Best regards,
      Julius

      Delete
  4. Tks for this quick feedback,

    Here is my test case:

    Steps
    -------
    1) Create 1 "Deploy Project" having one environment (ex: MyTemplateDeploy)
    2) Flag this environment as "IS_TEMPLATE = Yes"
    3) Define one variable (ex: MyVersion = V1)
    4) Create 1 "Deploy Project" having one environment (ex: Integration)
    5) Flag this environment as "LINKED_TEMPLATE_ID = xxxxxx"
    6) Define same variable as in Template (ex: MyVersion = V0)
    7) GoTo "Template Plugin" and execute "Replicate Deployments"

    Expected results
    ----------------
    "MyVersion" variable is having value "V1" in all environments linked to MyDeployTemplate


    Actuals results
    ----------------
    Jobs are well updated but not variables.

    Can you help?

    ReplyDelete
    Replies
    1. Hi Philippe,

      the existing variables are not touched. Only new ones are propagated. At the moment many people use the variables as customization point for the plans. For example tasks are identical and only a variable is different between environments containing the environment name.

      Julius

      Delete
  5. Hi Lulius,

    You are absolutely right.

    Nevertheless, in our business, we have several physical environments (ex: integration, uat, pre-production, ...).
    Each environment will host several components (micro services architecture).

    When updating some parameters on 1 component (ex: port, IP, etc...), I wish I wouldn't have to update same parameter on all Bamboo deploy project.

    Does it make sense?
    Can we achieve this goal using "Template Plugin" ?

    Regard,
    Philippe.

    ReplyDelete
    Replies
    1. Hi Philippe,

      I dont think this can fall under the templating scope, I can only make a "Bulk set variables values" as a separate feature. Let me try over the weekend.

      Julius

      Delete
    2. Hi Philippe,

      if you update to latest published you should find a new feature allowing you to replicate variable values in the main menu.

      Julius

      Delete
  6. Hi,

    I have a Build Template made of a Stage having 2 jobs.
    Each Job have several tasks.

    On the other hand, I have a Build Project depending on one of the templates jobs (described above).

    As a matter of fact, replication does not work.
    Here is nested exception:

    Thu Oct 20 17:34:59 EDT 2016 query did not return a unique result: 2; nested exception is org.hibernate.NonUniqueResultException: query did not return a unique result: 2Thu Oct 20 17:34:59 EDT 2016 query did not return a unique result: 2; nested exception is org.hibernate.NonUniqueResultException: query did not return a unique result: 2

    Do you have any clue??

    Regards,
    Philippe.

    ReplyDelete
    Replies
    1. Hi Philippe,

      this doesnt look like is coming from me. Can you check that all tasks have unique descriptions. That is the only case I encountered when replication did not work.

      Julius

      Delete
  7. Hi Julius,
    You gave me good clue...
    Description was different but one job was created by cloning an existing one.
    So I just re-created from scratch which solved the problem.

    Philippe.

    ReplyDelete
  8. Glad to help Philippe !

    Julius

    ReplyDelete
  9. Hi,
    I used "Replicate Deploy including permission scheme".
    Permission were well replicated over "environment permissions".
    Unfortunately, permission was not replicated over "Deploy project permission".
    Did I miss something?

    ReplyDelete
    Replies
    1. Hi Philippe,

      the plugin supports linking environments only, not projects unfortunately. Unfortunatelly the UI on the deployment projects cannot be customised at all in order to setup the replications, this is also the reason I had to use variables to link the environments.

      Best regards,
      Julius

      Delete
  10. Hi,

    I'm trying to get the templates working but I'm not seeing where I'm going wrong.

    1. create new plan T with checkout, maven build, script, etc
    2. mark plan T as a template in the Misc tab
    3. create new plan A with checkout
    4. select plan T as the template in plan A's Default Job
    5. select Template Tasks Definition in A
    6. save A

    When I run A manually, it only does the checkout and none of the tasks defined in T. When I edit A's job, I only see the checkout task.

    Any idea on what I'm doing wrong here?

    Trial version of Bamboo on version 5.14.0.2 on OS X using the embedded database.

    ReplyDelete
    Replies
    1. Any ideas how on to correct this?

      Delete
    2. Hi Terry,

      the replication between template and child plan is not done on the fly. In the main menu you can trigger a replication, once that is completed you should be able to see in plan A the exact same tasks as in T just source code repo should stay as it was.

      Delete
  11. Hi,

    Can you help me understand what the "Attempt to maintain task states" option does for build templates? Does this mean that if you have a task with the same name as a task in the template, you don't overwrite it?

    ReplyDelete
    Replies
    1. Hi Elli,

      I attempt to match task names and maintain the state of it - Enabled/Disabled, but task is always replicated.

      For example in template I have a task called Parse test results, in one plan using the template I have it enabled and another plan disabled. If Attempt to maintain task states is checked the task itself is being replicated but the state is not altered.

      Julius

      Delete
    2. Oh, thank you, that makes sense!

      Delete
  12. We've purchased the plugin and I'm beginning to adopt at scale. I'm having trouble because it is overwriting the key for the ssh deployment task. This isn't good for us because we use separate keys per server. Any ideas?

    ReplyDelete
    Replies
    1. ssh key must be a property at the task level. I think we got 2 options:

      - code change on my end to add some sort of filtering and disable certain properties from replication
      - use variables in the fields that you want to avoid overwriting

      Julius

      Delete
    2. For me it makes sense that the key/password/passphrase for this task type be excluded after the initial replication. Any idea how to use a variable to refer to the key file/contents?

      Delete
    3. If you are using the SSH task from Bamboo I dont think keys can be loaded via variables. In that case I can make a new feature on the plugin for you to exclude the key from replication.

      What version of Bamboo are you using ?

      Delete
    4. Hi Evan,

      I attempted to implement for you a new feature that should prevent transportation of plugin specific configuration in case is required.

      Under security of Bamboo, System Templates section you can define a regex that will match the blocked items. For your example, if you like to block replication of the key you can enter there private_key as a value and this will prevent the replication of private_key item.

      - oid: sdasdasd43453r
      description: abc
      pluginKey: com.atlassian.bamboo.plugins.bamboo-scp-plugin:sshtask
      configuration:
      encPassword: lsasasasarA==
      verifyFingerprint: 'false'
      host: 1.1.1.5
      private_key: "8H735OrgRCxD3sln4eCyP4oD1AnBZ6KS3kxtbzC3DjAciizOKy5X9uv19TfrkYJHWLZdWZUV/nx2\r\
      \nGiKRMkSiNrN/my6PPmzWW5Rlesj7baIRIxq2VfFTI8VkZtFseMQYvKKNottGyW4XLNbG6njg4aKo\r\
      \nvPwzr+MFLrQjuinxzYM7d9Y3QFF6BM0k"
      passphrase: ''
      authType: KEY
      command: ls
      username: bamboo

      For any other keys that you want to block just look in the YAML plan description under configuration section.

      Delete
  13. Hi Lulius,

    Can you please advise me who has access to run "Template Replication Operations" ? I am Babmoo admin and I cannot see this in the Templates drop down until I have ticked "Allow all users to manage templating engine"

    Thx,
    Terry

    ReplyDelete
    Replies
    1. any luck on this? I thought I should able to see "Template Replication Operations" without having tick "Allow all users to manage templating engine" because I am Bamboo admin.

      Delete
    2. The same page which is managing the replication is available in 2 places, under Administration -> Addons and main menu. The item in the main menu is only available if you allow all users to play around. The one in administration ... always on

      Julius

      Delete
  14. Hi Lulius,

    I have a user non-admin logged in, he can see the "Template" menu at the top, but when it clicked on it, it does not have any menu item, is this expected? Since we allow developers to update individual plan's misc tab to synchronize from which template, so should we allow them to do this or not in bulk?

    Thx,
    Terry

    ReplyDelete
    Replies
    1. any luck on this? although the developer cannot see the menu item when he clicks on Tempaltes, when I pass him the following URL: http://bamboo/plugins/servlet/admin/configurebuildtemplates , he can actually bulk edit the template linkage.

      Delete
    2. Hi Terry,

      seems you found a bug, I am raising it on the issue tracker on bitbucket and will sort it out asap.

      https://bitbucket.org/iuliushutuleac/bamboo-templatedplans-plugin/issues/29/permissions-on-servlet-should-be-checked

      Can you please tell me your bamboo version so I prioritize the release for that particular bamboo.


      Julius

      Delete
  15. This comment has been removed by the author.

    ReplyDelete