Skip to content

Unable to create multiple docker build tasks with single build.gradle file #4384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
krishnakekan619 opened this issue Apr 22, 2025 · 3 comments

Comments

@krishnakekan619
Copy link

Environment:
development

  • Jib version: 3.3.1
  • Build tool: Gradle
  • OS: ubuntu

Description of the issue:
I have two application with same root project and wanted to create two jib build tasks with build.gradle file but unable to achieve that
error: cannot create jib tasks as dorectly extending abstracttask is not supported
Expected behavior:

Steps to reproduce:

  1. added two jib tasks for container code in build.gradle
  2. with jenkins stage :: rungradle(build, jib, ....
  3. fails on above mentioned error

jib-gradle-plugin Configuration:

plugins {
    id 'java'
    id 'com.google.cloud.tools.jib' version '3.1.1'
}


repositories {
    mavenCentral()
}

dependencies {
    // your dependencies here
}

jibdevapp1 {
    from {
        image = 'gcr.io/distroless/java:11'
        auth {
            username = 'your-source-username'
            password = 'your-source-password'
        }
    }
    to {
        image = 'your-registry/your-image-name'
        auth {
            username = 'your-target-username'
            password = 'your-target-password'
        }
    }
    container {
        entrypoint = ['java', '-cp', '/app/classes:/app/libs/*', 'com.example.Main']
        creationTime = 'USE_CURRENT_TIMESTAMP'
        format = 'Docker'
    }
    extraDirectories {
        paths = ["${buildDir}/optf"]
        permissions = [
            '/optf/scripts/start.sh': '755'
        ]
    }
}
jibdevapp2 {
    from {
        image = 'gcr.io/distroless/java:11'
        auth {
            username = 'your-source-username'
            password = 'your-source-password'
        }
    }
    to {
        image = 'your-registry/your-image-name'
        auth {
            username = 'your-target-username'
            password = 'your-target-password'
        }
    }
    container {
        entrypoint = ['java', '-cp', '/app/classes:/app/libs/*', 'com.example.Main']
        creationTime = 'USE_CURRENT_TIMESTAMP'
        format = 'Docker'
    }
    extraDirectories {
        paths = ["${buildDir}/optf"]
        permissions = [
            '/optf/scripts/start.sh': '755'
        ]
    }
}
 task jibDockerBuild {
   group = "jib"
   description = "Build all Docker images"
   dependsOn 'jibdevapp21', 'jibdevapp2'
}

Log output:
Error::
cannot create task jibdevapp1 as directly extending abstractTask is not supported
Let me know if there is any workaround for this, i have also tried to create function of jib and provide the both images data as variable in loop but it still fails on the same error.
Additional Information:

@krishnakekan619
Copy link
Author

@mpeddada1 @chanseokoh any comment on above issues

@krishnakekan619
Copy link
Author

hey @blakeli0, Thanks for looking into it, any comment on above issue? is it possible to create two container images with single build.gradle file? if yes, then please provide me way to do this, thanks

@krishnakekan619
Copy link
Author

CC: @ldetmer @mpeddada1 @lqiu96

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants