コード例 #1
0
    def run(self):
        """
        run the plugin
        """

        try:
            build_json = json.loads(os.environ["BUILD"])
        except KeyError:
            self.log.error("No $BUILD env variable. Probably not running in build container")
            raise

        metadata = build_json.get("metadata", {})
        labels = metadata.get("labels", {})
        buildconfig = labels["buildconfig"]
        is_rebuild = labels.get(self.label_key) == self.label_value
        self.log.info("This is a rebuild? %s", is_rebuild)

        if not is_rebuild:
            # Update the BuildConfig metadata so the next Build
            # instantiated from it is detected as being an automated
            # rebuild
            kwargs = {}
            if 'namespace' in metadata:
                kwargs['namespace'] = metadata['namespace']

            osbs_conf = Configuration(conf_file=None, openshift_uri=self.url,
                                      use_auth=self.use_auth,
                                      verify_ssl=self.verify_ssl)
            osbs = OSBS(osbs_conf, osbs_conf)
            labels = {self.label_key: self.label_value}
            osbs.set_labels_on_build_config(buildconfig, labels, **kwargs)

        return is_rebuild
コード例 #2
0
    def run(self):
        """
        run the plugin
        """

        try:
            build_json = json.loads(os.environ["BUILD"])
        except KeyError:
            self.log.error("No $BUILD env variable. Probably not running in build container")
            raise

        metadata = build_json.get("metadata", {})
        labels = metadata.get("labels", {})
        buildconfig = labels["buildconfig"]
        is_rebuild = labels.get(self.label_key) == self.label_value
        self.log.info("This is a rebuild? %s", is_rebuild)

        if not is_rebuild:
            # Update the BuildConfig metadata so the next Build
            # instantiated from it is detected as being an automated
            # rebuild
            kwargs = {}
            if 'namespace' in metadata:
                kwargs['namespace'] = metadata['namespace']

            # FIXME: remove `openshift_uri` once osbs-client is released
            osbs_conf = Configuration(conf_file=None, openshift_uri=self.url,
                                      openshift_url=self.url,
                                      use_auth=self.use_auth,
                                      verify_ssl=self.verify_ssl)
            osbs = OSBS(osbs_conf, osbs_conf)
            labels = {self.label_key: self.label_value}
            osbs.set_labels_on_build_config(buildconfig, labels, **kwargs)

        return is_rebuild
コード例 #3
0
    def run(self):
        """
        run the plugin
        """

        try:
            build_json = json.loads(os.environ["BUILD"])
        except KeyError:
            self.log.error("No $BUILD env variable. Probably not running in build container")
            raise

        metadata = build_json.get("metadata", {})
        labels = metadata.get("labels", {})
        buildconfig = labels["buildconfig"]
        is_rebuild = labels.get(self.label_key) == self.label_value
        self.log.info("This is a rebuild? %s", is_rebuild)

        if not is_rebuild:
            # Update the BuildConfig metadata so the next Build
            # instantiated from it is detected as being an automated
            # rebuild
            kwargs = {}
            if 'namespace' in metadata:
                kwargs['namespace'] = metadata['namespace']

            # FIXME: remove `openshift_uri` once osbs-client is released
            osbs_conf = Configuration(conf_file=None, openshift_uri=self.url,
                                      openshift_url=self.url,
                                      use_auth=self.use_auth,
                                      verify_ssl=self.verify_ssl)
            osbs = OSBS(osbs_conf, osbs_conf)
            labels = {self.label_key: self.label_value}
            try:
                osbs.set_labels_on_build_config(buildconfig, labels, **kwargs)
            except OsbsResponseException as ex:
                if ex.status_code == 409:
                    # Someone else was modifying the build
                    # configuration at the same time. Try again.
                    self.log.debug("got status %d, retrying", ex.status_code)
                    osbs.set_labels_on_build_config(buildconfig, labels,
                                                    **kwargs)
                else:
                    raise

        return is_rebuild
コード例 #4
0
    def run(self):
        """
        run the plugin
        """

        metadata = get_build_json().get("metadata", {})
        labels = metadata.get("labels", {})
        buildconfig = labels["buildconfig"]
        is_rebuild = labels.get(self.label_key) == self.label_value
        self.log.info("This is a rebuild? %s", is_rebuild)

        if not is_rebuild:
            # Update the BuildConfig metadata so the next Build
            # instantiated from it is detected as being an automated
            # rebuild

            # FIXME: remove `openshift_uri` once osbs-client is released
            osbs_conf = Configuration(conf_file=None,
                                      openshift_uri=self.url,
                                      openshift_url=self.url,
                                      use_auth=self.use_auth,
                                      verify_ssl=self.verify_ssl,
                                      namespace=metadata.get(
                                          'namespace', None))
            osbs = OSBS(osbs_conf, osbs_conf)
            labels = {self.label_key: self.label_value}
            try:
                osbs.set_labels_on_build_config(buildconfig, labels)
            except OsbsResponseException as ex:
                if ex.status_code == 409:
                    # Someone else was modifying the build
                    # configuration at the same time. Try again.
                    self.log.debug("got status %d, retrying", ex.status_code)
                    osbs.set_labels_on_build_config(buildconfig, labels)
                else:
                    raise

        return is_rebuild
コード例 #5
0
    def run(self):
        """
        run the plugin
        """

        metadata = get_build_json().get("metadata", {})
        labels = metadata.get("labels", {})
        buildconfig = labels["buildconfig"]
        is_rebuild = labels.get(self.label_key) == self.label_value
        self.log.info("This is a rebuild? %s", is_rebuild)

        if not is_rebuild:
            # Update the BuildConfig metadata so the next Build
            # instantiated from it is detected as being an automated
            # rebuild

            # FIXME: remove `openshift_uri` once osbs-client is released
            osbs_conf = Configuration(conf_file=None, openshift_uri=self.url,
                                      openshift_url=self.url,
                                      use_auth=self.use_auth,
                                      verify_ssl=self.verify_ssl,
                                      namespace=metadata.get('namespace', None))
            osbs = OSBS(osbs_conf, osbs_conf)
            labels = {self.label_key: self.label_value}
            try:
                osbs.set_labels_on_build_config(buildconfig, labels)
            except OsbsResponseException as ex:
                if ex.status_code == 409:
                    # Someone else was modifying the build
                    # configuration at the same time. Try again.
                    self.log.debug("got status %d, retrying", ex.status_code)
                    osbs.set_labels_on_build_config(buildconfig, labels)
                else:
                    raise

        return is_rebuild