Example #1
0
 def run_step(self, data):
     for instruction in file_util.get_lines(DockerFileStep.FILE_DOCKERFILE):
         if self.is_instruction_entrypoint(instruction):
             message = self.get_change_message(instruction, data)
             self.log.warning(message)
             slack.send(message)
     return data
Example #2
0
    def inform_if_change_image(self, image_name, data):

        message = self.get_change_image_message(image_name, data)

        if message:
            self.log.warning(message)
            slack.send(message)
Example #3
0
    def run_step(self, data):

        data = self.add_build_information(data)

        self.write_updated_package_json(data)

        if not artifact.should_store():
            self.log.info('Branch not to be publish to NPM.')
            slack.send((f'The :git: branch *{data[pipeline_data.NPM_PACKAGE_NAME]} | '
                                 f' {environment.get_git_branch()}* '
                                 'is not a main branch, nor configured to be push to the NPM registry.'))

            return data

        if data[pipeline_data.NPM_VERSION_CHANGED]:
            self.log.info(
                'Package will be published. Local version is %s and '
                'latest version on npm before publish is %s', data[pipeline_data.NPM_PACKAGE_VERSION], data[pipeline_data.NPM_MAJOR_MINOR_LATEST])
            self.publish(data)
            slack.on_npm_publish(
                data[pipeline_data.NPM_PACKAGE_NAME], data[pipeline_data.NPM_PACKAGE_VERSION], data)
            self.step_ok()
        else:
            self.log.info('Skipping npm publish, no version change.')
            slack.on_npm_no_publish(data[pipeline_data.NPM_PACKAGE_NAME], data[pipeline_data.NPM_PACKAGE_VERSION])
            self.step_skipped()

        return data
Example #4
0
 def _log_warning_and_send_to_slack(self, filenames, data):
     self.log.warning('Possible password(s) or token(s) in the following files "%s"', filenames)
     self.log.infor('If ok, remove the warning by adding the file, or catalog to a /.scanignore file.')
     
     text = (f':rotating_light: <!here> *Possible password or token* in the following *{data[pipeline_data.IMAGE_NAME]}* file(s). \n'
            'If ok, remove the warning by adding the file, or catalog to `/.scanignore`.')
     slack.send(text=text, snippet=self.format_filnames(filenames), username="******")
Example #5
0
 def run_steps(self):
     try:
         self.log.info('Running npm pipeline')
         data = self.pipeline_steps[0].run_pipeline_step({})
     except PipelineException as p_ex:
         workspace = f'`{environment.get_project_root()}`'
         self.log.fatal('%s'.encode('UTF-8'), p_ex, exc_info=False)
         slack.send(f'<!here> *{workspace}*', snippet=p_ex.slack_message, username='******')
         print_util.red("Such bad, very learning")
         sys.exit(1)
Example #6
0
    def report_error_to_slack(self, message, ex):
        workspace = environment.get_project_root()
        if workspace:
            text = f'*{workspace}* \n{message}'

        slack.send(
            text=text,
            snippet=ex,
            icon=":no_entry:",
            username='******')
Example #7
0
    def run_step(self, data):
        if environment.get_push_public():
            if artifact.should_store():
                self.push_image(data)
            else:
                self.log.info(
                    'Branch not to be publish.')
                slack.send((f'The :git: branch *{data[pipeline_data.IMAGE_NAME]} | '
                                     f' {environment.get_git_branch()}* '
                                     'is not a main branch, nor configured to be push to Docker Hub.'))


        return data
Example #8
0
 def run_step(self, data):
     if environment.get_push_azure() and not environment.get_push_public():
         if artifact.should_store():
             self.push_image(data)
             self.step_ok()
         else:
             self.log.info('Branch not to be publish to Azure CR.')
             slack.send((
                 f'The :git: branch *{data[pipeline_data.IMAGE_NAME]}* | '
                 f' *{environment.get_git_branch()}* '
                 'is not pushed to Azure Registry. It is not the main branch, nor configured to be push.'
             ))
             self.step_skipped()
     return data
Example #9
0
    def run_step(self, data):
        from_line = self.get_from_line()
        if self.validate(from_line, data):
            self.log.info("'FROM:' statement '%s' in Dockerfile is valid.",
                          from_line)
            self.step_ok()
        else:
            text = (
                ":warning: *{}'s* Dockerfile is based on an old `{}` image, "
                "please upgrade! See https://hub.docker.com/r/kthse/{}/tags for :docker: images."
                .format(image_version_util.get_image(data), from_line,
                        self.get_base_image_name(from_line)))
            self.log.warning(text)
            self.step_warning()
            slack.send(text)

        return data
Example #10
0
File: run.py Project: KTH/evolene
def select_and_run_pipeline():

    logger = logging.getLogger(__name__)
    docker_conf = file_util.get_absolue_path('/docker.conf')
    has_docker_conf = os.path.isfile(docker_conf)
    npm_conf = file_util.get_absolue_path('/npm.conf')
    has_npm_conf = os.path.isfile(npm_conf)

    if has_docker_conf:
        logger.info("Has docker.conf")
        docker_pipeline = DockerDeployPipeline()
        docker_pipeline.run_pipeline()

    if has_npm_conf:
        logger.info("Has npm.conf")
        npm_pipeline = NpmPipeline()
        npm_pipeline.run_pipeline()

    if has_docker_conf is False and has_npm_conf is False:
        workspace = environment.get_project_root()
        text = f'Could not fins any `/docker.conf` or `/npm.conf` in repository *{workspace}*.'
        slack.send(text)
        logger.error(text)
        sys.exit(1)
Example #11
0
def log_and_slack(upgrades_information, name):
    log.info('New dependencies version(s) available: \n %s', upgrades_information)

    if environment.use_update_available():
        text = (f'*{name}* <https://www.npmjs.com/package/npm-check-updates|npm check updates> reported new version(s) available. Run `ncu -u` in the root of your project to update.')
        slack.send(text, snippet=upgrades_information, icon=':jenkins:')
Example #12
0
 def do_we_have_a_reason_to_party(self, data):
     message = self.get_party_message(data)
     if message:
         slack.send(self.get_party_message(data), icon=":parrot_party:")