Пример #1
0
 def test_correct_zip_artifact(self):
     result = create_artifact('.', '0.4.0', "kinesis-sink", 'zip',
                              'test-package-', '', ['setup.py'])
     self.assertEqual(
         result, {
             'artifact_name': 'test_package_0.4.0.zip',
             'artifact_path': './dist/kinesis-sink/test_package_0.4.0.zip'
         })
Пример #2
0
 def test_correct_asis_artifact(self):
     result = create_artifact('.', '0.4.0-M1',
                              "package name doesn't matter", 'asis',
                              'test-package-', '.jar',
                              ['path/to/binary.jar'])
     self.assertEqual(
         result, {
             'artifact_name': 'test-package-0.4.0-M1.jar',
             'artifact_path': './path/to/binary.jar'
         })
Пример #3
0
def upload_to_s3(args, local, package, target):
    """Upload artifact to AWS S3"""

    if args.make_artifact:

        # Run build commands
        if "build_commands" in package.keys():
            pack.execute_commands(package["build_commands"])

        for artifact in package["artifacts"]:
            artifact_file = pack.create_artifact(
                local['root_dir'], package['version'], package['name'],
                artifact['type'], artifact['prefix'], artifact['suffix'],
                artifact['binary_paths'])

            # Process all S3 locations
            for location in get_locations(package):
                full_s3_path = get_full_path(location, artifact_file)

                client = boto3.client(
                    's3',
                    region_name=location.region,
                    aws_access_key_id=target['access_key_id'],
                    aws_secret_access_key=target['secret_access_key'])
                transfer = S3Transfer(client)

                if package['override']:
                    transfer.upload_file(artifact_file['artifact_path'],
                                         location.bucket, full_s3_path)
                else:
                    try:
                        transfer.download_file(location.bucket, full_s3_path,
                                               tempfile.mktemp())
                        if package['continue_on_conflict']:
                            logger.log_info(
                                "Artifact [%s] exists, but continue_on_conflict flag is true, not failing deploy..."
                                % full_s3_path)
                        else:
                            raise ValueError("Artifact at %s already exists" %
                                             (full_s3_path, ))
                    except ClientError as e:
                        if e.response['Error']['Code'] == '404':
                            transfer.upload_file(
                                artifact_file['artifact_path'],
                                location.bucket, full_s3_path)
                            logger.log_info(
                                "Artifact uploaded to {}".format(location))
                        else:
                            logger.log_info(
                                "continue_on_conflict flag is true, not failing release..."
                            )
                            raise

    else:
        logger.log_info("make-artifact flag was not passed. Do nothing")
Пример #4
0
def deploy_to_bintray(args, local, package, target):
    """Deploys the package to Bintray"""

    # Make the version
    if args.make_version:
        retval_1 = create_bintray_version(
            package["version"],
            package["name"],
            package["repo"],
            package["user_org"],
            target["user"],
            target["password"]
        )
        if retval_1 is False:
            raise ValueError("Could not create new Bintray version for the package!")

    # Make the artifacts
    if args.make_artifact:

        # Run build commands
        if "build_commands" in package.keys():
            pack.execute_commands(package["build_commands"])

        # Build artifacts
        for artifact in package["artifacts"]:
            retval_2 = pack.create_artifact(
                local["root_dir"],
                package["version"],
                package["name"],
                artifact["type"],
                artifact["prefix"],
                artifact["suffix"],
                artifact["binary_paths"]
            )

            # Upload the artifacts
            if args.make_artifact and args.upload_artifact:
                retval_3 = upload_bintray_artifact(
                    package["version"],
                    package["name"],
                    package["repo"],
                    package["user_org"],
                    target["user"],
                    target["password"],
                    retval_2["artifact_name"],
                    retval_2["artifact_path"],
                    "1" if package["publish"] else "0",
                    "1" if package["override"] else "0",
                    package["continue_on_conflict"]
                )
                if retval_3 is False:
                    raise ValueError("Could not upload artifact to Bintray!")