GoogleContainerTools / GoogleContainerTools/jib

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

Open
#4,384 5 comments 0 reactions 0 assignees View on GitHub
priority: p3 type: feature request
Dominant language
Java
Stars
14.5k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

**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**:
```groovy
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**:

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.