Beispiel #1
0
    def main(self):
        info(
            'Setting a lock on other pipeline "validate-json", and trying to trigger it that pipeline'
        )

        # @todo: Timezone in the container must match host's timezone

        self.locks.create_lock('quay-push',
                               expires_in=timedelta(hours=5),
                               regexp='riotkit',
                               pipeline='validate-json')

        info('Spawning a pipeline "validate-json"')
        info(
            'Log:',
            pipeline(name='validate-json',
                     payload=self._get_payload_example()))

        # @todo: Move to second example
        with self.locks.lock('locks-example',
                             mode=self.locks.MODE_WAIT_UNTIL_RELEASED,
                             expires_in=timedelta(hours=2),
                             partial=True):
            info(
                'Hello, any next execution will need to wait until this block ends, because its partial=True'
            )
            sleep(1)

        with self.locks.lock('locks-example',
                             mode=self.locks.MODE_WAIT_UNTIL_RELEASED,
                             partial=False):
            info(
                'No any new Pipeline execution can be started while this block is executing.'
            )
            sleep(1)
 def main(self):
     with stage('Send a notification'):
         #  More complex case: to construct with additional params use get_tool(Slack, some_param='some-value')
         slack: Slack = self.context().get_tool(Slack)
         info('Slack tool built:', slack)
         info('Attempt to send a message:',
              slack.send('Hello from Boautomate'))
Beispiel #3
0
    def _get_tags_to_propagate_for_tag(self, tag: str):
        """ eg. for 5.0.5 => 5.0 and 5 """

        tags_to_push = []
        split = tag.split(self.separator)
        left = len(split)

        while left != 1 and len(split) > 1:
            left -= 1
            tags_to_push.append(".".join(split[0:left]))

        if self.latest_stable_name and self._is_tag_latest_stable(tag):
            tags_to_push.append(self.latest_stable_name)

        info('Will tag ' + tag + ' as ' + str(tags_to_push) + '')

        return tags_to_push
Beispiel #4
0
    def main(self):
        """
        Pipeline method
        :return:
        """

        with stage('Validate requirements'):
            self.assert_facts_present([DockerRepositoryFact.identify()])
            self.assert_what_is_going_on_at_least_one_of([ACTION_DOCKER_PUSH])

            registry_fact = self.context().get_fact(
                DockerRepositoryFact.identify())  # type: DockerRepositoryFact

            if not registry_fact.updated_tags:
                info('No tags pushed')
                return

            info('Repository:', registry_fact.url)
            info('Incoming tags to process:', registry_fact.updated_tags)

        with stage('Prepare regexp'):
            self.regexp = re.compile(r'^v?([0-9.+]+)$')
            self.latest_stable_name = 'latest-stable'
            self.separator = '.'

        with stage('Validate tags'):
            self._stage_validate_tags(registry_fact.updated_tags)

        with stage('Propagate tags'):
            try:
                results = self._stage_propagate_tags(
                    registry_fact.updated_tags)

            except RegistryException as e:
                info('Error occurred: ' + str(e))
                info('Response: ' + str(e.response))

                raise e

        with stage('Notify'):
            success('Pushed tags:', results)
Beispiel #5
0
    def _stage_propagate_tags(self, tags: list) -> list:
        """
        Stage method, propagates multiple tags

        :param tags:
        :return:
        """

        origin_tag: str
        results = []

        for origin_tag in tags:
            if not self._is_valid_version_to_propagate(origin_tag):
                info('Tag %s does not match regexp' % origin_tag)
                continue

            for propagated_tag in self._get_tags_to_propagate_for_tag(
                    origin_tag):
                self.context().docker_registry().current_repository().tag(
                    propagated_tag, origin_tag)
                results.append(propagated_tag)

        return results
 def main(self):
     info('Message from query string "message": ' + str(self.get_query_argument('message')))
     info('Message from header "Message": ' + str(self.get_header('Message')))
     info('Message from overridable parameter "message": ' + str(self.get_overridable_param('message')))
     info('Message from pipeline parameter "message": ' + str(self.get_param('message')))
Beispiel #7
0
    def _stage_validate_tags(self, tags: list):
        self.present_tags = self.context().docker_registry(
        ).current_repository().tags()
        self._assert_contains(tags, self.present_tags)

        info('Present tags:', self.present_tags)