Sha256: c7067e9a760834bc4b3ef52e5c5a33892cfe5f53dc2ecd8cb0225f5e7a61c32c

Contents?: true

Size: 1.72 KB

Versions: 1

Compression:

Stored size: 1.72 KB

Contents

module Bozo::Hooks

  # Hook to create a release in Octopus.
  class OctopusCreateRelease

    def initialize
      @deploy_to = nil
      @display_progress = false
    end

    def required_tools
      :octopus_tools
    end

    # Specify the name of the Octopus Deploy project to create a release for.
    def project(value)
      @octopus_project = value
    end

    # The server address of Octopus.
    def server(value)
      @octopus_server = value
    end

    # The api key to authorise to Octopus with.
    def api_key(value)
      @octopus_api_key = value
    end

    # Specify the environment in Octopus to deploy to.
    def deploy_to(value)
      @deploy_to = value
    end

    # Write the deployment log from Octopus. If false
    # then the hook does not wait for the release to complete.
    def display_progress(value)
      @display_progress = value
    end

    def post_publish
      return unless build_server?
      log_info "Creating release in Octopus for #{env['BUILD_VERSION_FULL']}"

      args = []
      args << File.expand_path(File.join('build', 'tools', 'octopustools', 'Octo.exe'))
      args << 'create-release'
      args << "--project \"#{@octopus_project}\""
      args << "--version #{env['BUILD_VERSION_FULL']}"
      args << "--packageversion #{env['BUILD_VERSION_FULL']}"
      args << "--server #{@octopus_server}"
      args << "--apiKey #{@octopus_api_key}"
      args << "--releaseNotes \"[Build #{env['BUILD_VERSION_FULL']}](#{env['BUILD_URL']})\""

      if @display_progress
        args << '--progress'
      end

      if @deploy_to
        args << "--deployto=#{@deploy_to}"
      end

      execute_command :octo, args
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bozo-scripts-0.10.6 lib/bozo/hooks/octopus_create_release.rb