Ejemplo n.º 1
0
        name = args.name
        tag = args.tag
        priv_image = report.items()[0][1]

        if not name:
            [repository, name, _] = re.split(r'[/:]', priv_image)

        if not tag:
            if 'git-tag' in report:
                priv_image = report['git-tag']
                [repository, name, tag] = re.split(r'[/:]', priv_image)
            else:
                print("Missing 'git-tag' in docker build artifact. Aborting...")
                sys.exit(1)

        pub_image = '{0}/{1}:{2}'.format(args.organization, name, tag)

        if args.user_priv and args.password_priv:
            docker.login(args.user_priv, args.password_priv, repository)

        if args.user_pub and args.password_pub:
            docker.login(args.user_pub, args.password_pub)

        docker.pull_image(priv_image)
        docker.tag_image(priv_image, pub_image)
        docker.push_image(pub_image)
        docker.remove_image(priv_image)
        docker.remove_image(pub_image)

        write_report(priv_image, pub_image)
Ejemplo n.º 2
0
        dest='publish')

    parser.add_argument(
        '--remove',
        action='store_true',
        default=False,
        help='remove local docker image after build',
        dest='remove')

    [args, pass_args] = parser.parse_known_args()
    tags = get_tags()
    tags.extend([('custom-{0}'.format(i), tag) for i, tag in enumerate(
        args.tags)])

    if args.user and args.password:
        docker.login(args.user, args.password, args.repository)

    image = '{0}/{1}:{2}'.format(args.repository, args.name, tags[0][1])

    docker.build_image(image, pass_args)
    images = [(tags[0][0], image)]

    for tag in tags[1:]:
        image_tag = '{0}/{1}:{2}'.format(args.repository, args.name, tag[1])
        docker.tag_image(image, image_tag)
        images.append((tag[0], image_tag))

    for _, image in images:
        if args.publish:
            docker.push_image(image)
Ejemplo n.º 3
0
                        help='publish docker to the repository',
                        dest='publish')

    parser.add_argument('--remove',
                        action='store_true',
                        default=False,
                        help='remove local docker image after build',
                        dest='remove')

    [args, pass_args] = parser.parse_known_args()
    tags = get_tags()
    tags.extend([('custom-{0}'.format(i), tag)
                 for i, tag in enumerate(args.tags)])

    if args.user and args.password:
        docker.login(args.user, args.password, args.repository)

    image = '{0}/{1}:{2}'.format(args.repository, args.name, tags[0][1])

    docker.build_image(image, pass_args)
    images = [(tags[0][0], image)]

    for tag in tags[1:]:
        image_tag = '{0}/{1}:{2}'.format(args.repository, args.name, tag[1])
        docker.tag_image(image, image_tag)
        images.append((tag[0], image_tag))

    for _, image in images:
        if args.publish:
            docker.push_image(image)