Skip to content
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

k8s:build failed because .git folder is copied to target #590

Closed
yaakov-berkovitch opened this issue Feb 28, 2021 · 28 comments
Closed

k8s:build failed because .git folder is copied to target #590

yaakov-berkovitch opened this issue Feb 28, 2021 · 28 comments
Assignees
Labels
bug Something isn't working Waiting on feedback Issues that require feedback from User/Other community members
Milestone

Comments

@yaakov-berkovitch
Copy link

Description

The k8s:build action copies the .git folder to target and then failed to build the docker image.

Info

  • Eclipse JKube version : 1.1.0
  • Maven version (mvn -v) :
Apache Maven 3.0.5 (Red Hat 3.0.5-17)
Maven home: /usr/share/maven
Java version: 11.0.9, vendor: AdoptOpenJDK
Java home: /usr/lib/jvm/adoptopenjdk-11-openj9
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1160.11.1.el7.x86_64", arch: "amd64", family: "unix"
  • Kubernetes / Red Hat OpenShift setup and version : 1.20

  • If it's a bug, how to reproduce :
    Clone a git repository. Then, execute the k8s:build action. The following error is shown:

[ERROR] k8s: Failed to execute the build [Error while trying to build the image: C:\dev\tmp\jkube-test\hello-world\target\docker\asms\hello-world\0.1.0\build\target\.git\objects\pack\pack-196b9336d55bf0c758ab92782f761f62fd0f95f4.idx]

To reproduce the issue, you can use the attached project. Then do:

  1. mvn clean install
  2. mvn k8s:build

jkube-test.zip

@manusa
Copy link
Member

manusa commented Mar 1, 2021

Will probably get fixed by #529 -> #567

@yaakov-berkovitch
Copy link
Author

Thanks @manusa . Any workaround you can recommend ? Because it makes it unusable for the moment 😟

@manusa
Copy link
Member

manusa commented Mar 1, 2021

Any workaround you can recommend ?

Don't use the simplified Dockerfile workflow. So probably your project looks like: https://github.com/eclipse/jkube/tree/master/quickstarts/maven/docker-file-simple

If you use any of the other approaches in any of the 4 profiles of https://github.com/eclipse/jkube/tree/master/quickstarts/maven/docker-file-provided you should be fine.

@manusa
Copy link
Member

manusa commented Mar 1, 2021

OK; just saw your reproducer project.
Just don't use the ${project.basedir} as the docker contextDir, make it all relative to the target dir

@yaakov-berkovitch
Copy link
Author

Thanks @manusa. Your tip works fine.

@ochstobi
Copy link

ochstobi commented Mar 30, 2021

I have the same problem.
My plugin-config is the following:

<profile>
    <id>s2i-chained-local</id>
    <properties>
        <jkube.build.strategy>s2i</jkube.build.strategy>
        <jkube.resourceDir>${project.basedir}/src/main/jkube/s2i-chained-local</jkube.resourceDir>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.eclipse.jkube</groupId>
                <artifactId>openshift-maven-plugin</artifactId>
                <version>${openshift-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <id>s2i-chained-local</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>resource</goal>
                            <goal>apply</goal>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <namespace>${os_project}</namespace>
                    <resources>
                        <labels>
                            <all>
                                <property>
                                    <name>app</name>
                                    <value>${os_app_name}</value>
                                </property>
                            </all>
                        </labels>
                        <!-- This section seems to be ignored -->
                        <openshiftBuildConfig>
                            <requests>
                                <cpu>${request_cpu_build}</cpu>
                                <memory>${request_memory_build}</memory>
                            </requests>
                            <limits>
                                <cpu>${limit_cpu_build}</cpu>
                                <memory>${limit_memory_build}</memory>
                            </limits>
                        </openshiftBuildConfig>
                    </resources>
                    <images>
                        <image>
                            <name>${os_app_name}-build</name>
                            <build>
                                <env>
                                    <MAVEN_COMMANDLINE>${maven_commandline}</MAVEN_COMMANDLINE>
                                </env>
                                <assembly>
                                    <inline>
                                        <fileSets>
                                            <fileSet>
                                                <directory>${project.basedir}/../../</directory><!-- Projects sources are 2 levels above openshift maven-module -->
                                                <excludes><!-- excludes are not working as expected, see edit below -->
                                                    <exclude>.git</exclude>
                                                    <exclude>target</exclude>
                                                </excludes>
                                            </fileSet>
                                        </fileSets>
                                    </inline>
                                    <name>.</name>
                                </assembly>
                                <from>
                                    ${registry}/${namespace}/${builder}:${version}
                                </from>
                            </build>
                        </image>
                    </images>
                </configuration>
            </plugin>
        </plugins>
    </build>
</profile>

EDIT: I found out that the excludes are applied to late to avoid the .git folder error. Alle resources are copied first to the output directory and then the exclusions are deleted. But in between these two steps the error with the .git folder is thrown. To avoid that, the includes can be used. Unlike the exclude only the resources that are included are copied in the build step.

@manusa
Copy link
Member

manusa commented Apr 13, 2021

This issue should be fixed in the latest 1.2.0 release.

Could you please confirm?

@ochstobi
Copy link

I can't confirm. The problem persists with v1.2.0 in s2i local build with excludes like in my example above.

Failed to execute goal org.eclipse.jkube:openshift-maven-plugin:1.2.0:build (s2i-chained-local) on project springrest.openshift: Failed to execute the build: Unable to create the build archive: C:\springrest\openshift\target\docker\springrest-build\build\.\.git\objects\00\163521cb06fd599fa4f8d74b6c5b81fed9d98d

@rohanKanojia
Copy link
Member

@ochstobi : Could you please try creating .jkube-dockerignore file and putting .git/** inside it?

@ochstobi
Copy link

@rohanKanojia I confirm that this is working. But only for .git/**. If I add other folders/files they are not ignored.

.git/**
.idea/**
.mvn/**
target/**
mvnw
mvnw.cmd
README.md

@manusa manusa added this to Backlog in Sprint #200 Apr 14, 2021
@manusa manusa added the bug Something isn't working label Apr 14, 2021
@rohanKanojia
Copy link
Member

Are you sure about that? For me all specified folders seem to be getting ignored. I tested this on https://github.com/r0haaaan/jkube-dockerfile-test project which has this .jkube-dockerignore file:

target/classes/**
target/maven-status/**
src/**
pom.xml
docker-file-simple.iml
jkube-dockerinclude

I do k8s:build and check contents of target/docker directory:

jkube-dockerfile-test : $ tree target/docker -a
target/docker
├── build.timestamp
└── jkube
    └── docker-file-simple
        └── 1.2.0
            ├── build
            │   ├── Dockerfile
            │   └── maven
            │       ├── Dockerfile
            │       ├── docker-file-simple.jar
            │       ├── .git
            │       │   ├── branches
            │       │   ├── config
            │       │   ├── description
            │       │   ├── HEAD
            │       │   ├── hooks
            │       │   │   ├── applypatch-msg.sample
            │       │   │   ├── commit-msg.sample
            │       │   │   ├── fsmonitor-watchman.sample
            │       │   │   ├── post-update.sample
            │       │   │   ├── pre-applypatch.sample
            │       │   │   ├── pre-commit.sample
            │       │   │   ├── pre-merge-commit.sample
            │       │   │   ├── prepare-commit-msg.sample
            │       │   │   ├── pre-push.sample
            │       │   │   ├── pre-rebase.sample
            │       │   │   ├── pre-receive.sample
            │       │   │   └── update.sample
            │       │   ├── index
            │       │   ├── info
            │       │   │   └── exclude
            │       │   ├── logs
            │       │   │   ├── HEAD
            │       │   │   └── refs
            │       │   │       ├── heads
            │       │   │       │   └── master
            │       │   │       └── remotes
            │       │   │           └── origin
            │       │   │               └── HEAD
            │       │   ├── objects
            │       │   │   ├── 04
            │       │   │   │   └── e212d7d69c3b4cbb8ab8ebe87610f38a1ee5c4
            │       │   │   ├── 0b
            │       │   │   │   └── 47282267ecd59c4b666d891a8136d79145e013
            │       │   │   ├── 0d
            │       │   │   │   └── 2b7261890fb77ce2dc933896015a0254b37b4c
            │       │   │   ├── 24
            │       │   │   │   └── 473ac970f28c45b848fe5c6df21df2a92648ad
            │       │   │   ├── 6c
            │       │   │   │   └── 9d9fcd0b634759b85c8728cdcf6144dafd55ca
            │       │   │   ├── 6d
            │       │   │   │   └── 35923d91d97ebdc571cdf3859cb31866f4ba84
            │       │   │   ├── a6
            │       │   │   │   └── 2354208b4d93375702b9c3c88bbbda0e1eb043
            │       │   │   ├── b8
            │       │   │   │   └── e8510166e025756b176c3f1687c88cfcbc42c8
            │       │   │   ├── d4
            │       │   │   │   └── 0ccd4758e1b7602f6c100e13d8d832dfa4adf9
            │       │   │   ├── d5
            │       │   │   │   └── 12bf73487d02a9cfe2e52f34b2050916d07dd5
            │       │   │   ├── dc
            │       │   │   │   └── 328e61c482c6a9d0fe1510e6adc4101915e904
            │       │   │   ├── e1
            │       │   │   │   └── 5f6ec9f9c8862b31bf5c83655837133ff836f5
            │       │   │   ├── e9
            │       │   │   │   └── ac9da2611a23ea5231921ab18609d37fa89fac
            │       │   │   ├── ee
            │       │   │   │   └── c52115fe2a89c0ca00ce084fb9a7298c3300a5
            │       │   │   ├── f5
            │       │   │   │   └── 95fdf15af098e059810a2a8f24675c79bb3dd2
            │       │   │   ├── fb
            │       │   │   │   └── 566a928a13b6b79d22948044a13cc6ecf983bf
            │       │   │   ├── info
            │       │   │   └── pack
            │       │   ├── packed-refs
            │       │   └── refs
            │       │       ├── heads
            │       │       │   └── master
            │       │       ├── remotes
            │       │       │   └── origin
            │       │       │       └── HEAD
            │       │       └── tags
            │       ├── .gitignore
            │       ├── .idea
            │       │   ├── compiler.xml
            │       │   ├── encodings.xml
            │       │   ├── .gitignore
            │       │   ├── jarRepositories.xml
            │       │   ├── libraries
            │       │   │   ├── Maven__ch_qos_logback_logback_classic_1_2_3.xml
            │       │   │   ├── Maven__ch_qos_logback_logback_core_1_2_3.xml
            │       │   │   ├── Maven__com_fasterxml_classmate_1_5_1.xml
            │       │   │   ├── Maven__com_fasterxml_jackson_core_jackson_annotations_2_10_4.xml
            │       │   │   ├── Maven__com_fasterxml_jackson_core_jackson_core_2_10_4.xml
            │       │   │   ├── Maven__com_fasterxml_jackson_core_jackson_databind_2_10_4.xml
            │       │   │   ├── Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_10_4.xml
            │       │   │   ├── Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_10_4.xml
            │       │   │   ├── Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_10_4.xml
            │       │   │   ├── Maven__io_micrometer_micrometer_core_1_3_8.xml
            │       │   │   ├── Maven__jakarta_annotation_jakarta_annotation_api_1_3_5.xml
            │       │   │   ├── Maven__jakarta_validation_jakarta_validation_api_2_0_2.xml
            │       │   │   ├── Maven__org_apache_logging_log4j_log4j_api_2_12_1.xml
            │       │   │   ├── Maven__org_apache_logging_log4j_log4j_to_slf4j_2_12_1.xml
            │       │   │   ├── Maven__org_apache_tomcat_embed_tomcat_embed_core_9_0_34.xml
            │       │   │   ├── Maven__org_apache_tomcat_embed_tomcat_embed_el_9_0_34.xml
            │       │   │   ├── Maven__org_apache_tomcat_embed_tomcat_embed_websocket_9_0_34.xml
            │       │   │   ├── Maven__org_hdrhistogram_HdrHistogram_2_1_11.xml
            │       │   │   ├── Maven__org_hibernate_validator_hibernate_validator_6_0_19_Final.xml
            │       │   │   ├── Maven__org_jboss_logging_jboss_logging_3_4_1_Final.xml
            │       │   │   ├── Maven__org_latencyutils_LatencyUtils_2_0_3.xml
            │       │   │   ├── Maven__org_slf4j_jul_to_slf4j_1_7_30.xml
            │       │   │   ├── Maven__org_slf4j_slf4j_api_1_7_30.xml
            │       │   │   ├── Maven__org_springframework_boot_spring_boot_2_2_7_RELEASE.xml
            │       │   │   ├── Maven__org_springframework_boot_spring_boot_actuator_2_2_7_RELEASE.xml
            │       │   │   ├── Maven__org_springframework_boot_spring_boot_actuator_autoconfigure_2_2_7_RELEASE.xml
            │       │   │   ├── Maven__org_springframework_boot_spring_boot_autoconfigure_2_2_7_RELEASE.xml
            │       │   │   ├── Maven__org_springframework_boot_spring_boot_starter_2_2_7_RELEASE.xml
            │       │   │   ├── Maven__org_springframework_boot_spring_boot_starter_actuator_2_2_7_RELEASE.xml
            │       │   │   ├── Maven__org_springframework_boot_spring_boot_starter_json_2_2_7_RELEASE.xml
            │       │   │   ├── Maven__org_springframework_boot_spring_boot_starter_logging_2_2_7_RELEASE.xml
            │       │   │   ├── Maven__org_springframework_boot_spring_boot_starter_tomcat_2_2_7_RELEASE.xml
            │       │   │   ├── Maven__org_springframework_boot_spring_boot_starter_validation_2_2_7_RELEASE.xml
            │       │   │   ├── Maven__org_springframework_boot_spring_boot_starter_web_2_2_7_RELEASE.xml
            │       │   │   ├── Maven__org_springframework_spring_aop_5_2_6_RELEASE.xml
            │       │   │   ├── Maven__org_springframework_spring_beans_5_2_6_RELEASE.xml
            │       │   │   ├── Maven__org_springframework_spring_context_5_2_6_RELEASE.xml
            │       │   │   ├── Maven__org_springframework_spring_core_5_2_6_RELEASE.xml
            │       │   │   ├── Maven__org_springframework_spring_expression_5_2_6_RELEASE.xml
            │       │   │   ├── Maven__org_springframework_spring_jcl_5_2_6_RELEASE.xml
            │       │   │   ├── Maven__org_springframework_spring_web_5_2_6_RELEASE.xml
            │       │   │   ├── Maven__org_springframework_spring_webmvc_5_2_6_RELEASE.xml
            │       │   │   └── Maven__org_yaml_snakeyaml_1_25.xml
            │       │   ├── misc.xml
            │       │   ├── modules.xml
            │       │   ├── .name
            │       │   ├── vcs.xml
            │       │   └── workspace.xml
            │       ├── src
            │       └── target
            │           ├── classes
            │           ├── docker-file-simple.jar
            │           ├── docker-file-simple.jar.original
            │           ├── generated-sources
            │           │   └── annotations
            │           ├── maven-archiver
            │           │   └── pom.properties
            │           └── maven-status
            ├── tmp
            │   └── docker-build.tar
            └── work

49 directories, 100 files

I modify my .jkube-dockerignore file to ignore .git and .idea as well:

jkube-dockerfile-test : $ cat .jkube-dockerignore 
.git
.git/**
.idea
.idea/**
target/classes/**
target/maven-status/**
src/**
pom.xml
docker-file-simple.iml
jkube-dockerinclude

When I run mvn k8s:build, I was able to see both of them ignored:

jkube-dockerfile-test : $ tree target/docker -a
target/docker
├── build.timestamp
└── jkube
    └── docker-file-simple
        └── 1.2.0
            ├── build
            │   ├── Dockerfile
            │   └── maven
            │       ├── Dockerfile
            │       ├── docker-file-simple.jar
            │       ├── .gitignore
            │       ├── src
            │       └── target
            │           ├── classes
            │           ├── docker-file-simple.jar
            │           ├── docker-file-simple.jar.original
            │           ├── generated-sources
            │           │   └── annotations
            │           ├── maven-archiver
            │           │   └── pom.properties
            │           └── maven-status
            ├── tmp
            │   └── docker-build.tar
            └── work

14 directories, 9 files

@manusa
Copy link
Member

manusa commented Apr 14, 2021

Please also confirm your OS

@ochstobi
Copy link

I am working on Windows 10. Sorry I did a mistake before. In fact the .jkube-dockerignore isn't considered at all in my setup.

My .jkube-dockerignore is this:

.git/**
.idea/**
.mvn/**
target/**
mvnw
mvnw.cmd

and is located in /cicd/openshift/.jkube-dockerignore (same folder als the pom.xml which is executing the plugin).

I have the following structure:

C:/jkube-test/.
|   mvnw
|   mvnw.cmd
|   pom.xml <-- Parent pom for the spring applications modules
|   README.md
|   
+---.git
    | endless git folders/files...
+---.idea
|   |   endless intellij folders/files...
|   
+---.mvn
|   \---wrapper
|           maven-wrapper.jar
|           maven-wrapper.properties
|           
+---cicd
|   \---openshift
|       |   .gitignore
|       |   .jkube-dockerignore
|       |   pom.xml <-- Submodule which is triggering the openshift build
|       |   springrest.cicd.openshift.iml
|       |   
|       +---src
|       |   \---main
|       |       \---jkube
|       |           +---s2i-chained-local
|       |           |       build-buildconfig.yaml
|       |           |       build-imagestream.yaml
|       |           |       deployment.yaml
|       |           |       keystore-secret.yaml
|       |           |       route.yaml
|       |           |       run-buildconfig.yaml
|       |           |       run-imagestream.yaml
|       |           |       service.yaml
|       |           |       
|       \---target
|           |   s2i-env-springrest-build
|           |   
|           +---classes
|           |   \---META-INF
|           |       \---jkube
|           |           |   openshift.yml
|           |           |   
|           |           \---openshift
|           |                   springrest-build-imagestream.yml
|           |                   springrest-build-s2i-buildconfig.yml
|           |                   springrest-deploymentconfig.yml
|           |                   springrest-imagestream.yml
|           |                   springrest-keystore-secret-secret.yml
|           |                   springrest-route.yml
|           |                   springrest-run-buildconfig.yml
|           |                   springrest-service.yml
|           |                   
|           +---docker
|           |   |   build.timestamp
|           |   |   
|           |   \---springrest-build
|           |       +---build
|           |       |   |   mvnw
|           |       |   |   mvnw.cmd
|           |       |   |   pom.xml
|           |       |   |   README.md
|           |       |   |   
|           |       |   +---.git
|           |       |   |   |   copied git folders/files
|           |       |   +---.idea
|           |       |   |   |   copied intellij folders/files         
|           |       |   +---.mvn
|           |       |   |   \---wrapper
|           |       |   |           maven-wrapper.jar
|           |       |   |           maven-wrapper.properties
|           |       |   |           
|           |       |   +---cicd
|           |       |   |   \---openshift
|           |       |   |       |   .gitignore
|           |       |   |       |   .jkube-dockerignore
|           |       |   |       |   pom.xml
|           |       |   |       |   springrest.cicd.openshift.iml
|           |       |   |       |   
|           |       |   |       +---src
|           |       |   |       |   \---main
|           |       |   |       |       \---jkube
|           |       |   |       |           +---s2i-chained-local
|           |       |   |       |           |       build-buildconfig.yaml
|           |       |   |       |           |       build-imagestream.yaml
|           |       |   |       |           |       deployment.yaml
|           |       |   |       |           |       keystore-secret.yaml
|           |       |   |       |           |       route.yaml
|           |       |   |       |           |       run-buildconfig.yaml
|           |       |   |       |           |       run-imagestream.yaml
|           |       |   |       |           |       service.yaml
|           |       |   |       |           |       
|           |       |   |       |                   
|           |       |   |       \---target
|           |       |   |           |   s2i-env-springrest-build
|           |       |   |           |   
|           |       |   |           +---classes
|           |       |   |           |   \---META-INF
|           |       |   |           |       \---jkube
|           |       |   |           |           |   openshift.yml
|           |       |   |           |           |   
|           |       |   |           |           \---openshift
|           |       |   |           |                   springrest-build-imagestream.yml
|           |       |   |           |                   springrest-build-s2i-buildconfig.yml
|           |       |   |           |                   springrest-deploymentconfig.yml
|           |       |   |           |                   springrest-imagestream.yml
|           |       |   |           |                   springrest-keystore-secret-secret.yml
|           |       |   |           |                   springrest-route.yml
|           |       |   |           |                   springrest-run-buildconfig.yml
|           |       |   |           |                   springrest-service.yml
|           |       |   |           |                   
|           |       |   |           +---docker
|           |       |   |           |   |   build.timestamp
|           |       |   |           |   |   
|           |       |   |           |   \---springrest-build
|           |       |   |           |       +---build
|           |       |   |           |       +---tmp
|           |       |   |           |       \---work
|           |       |   |           \---jkube
|           |       |   |               |   build-buildconfig.yaml
|           |       |   |               |   build-imagestream.yaml
|           |       |   |               |   deployment.yaml
|           |       |   |               |   keystore-secret.yaml
|           |       |   |               |   route.yaml
|           |       |   |               |   run-buildconfig.yaml
|           |       |   |               |   run-imagestream.yaml
|           |       |   |               |   service.yaml
|           |       |   |               |   
|           |       |   |               \---applyJson
|           |       |   |                   \---my-namespace
|           |       |   |                           buildconfig-springrest-build-s2i.json
|           |       |   |                           buildconfig-springrest-run.json
|           |       |   |                           deploymentconfig-springrest.json
|           |       |   |                           route-springrest.json
|           |       |   |                           secret-springrest-keystore-secret.json
|           |       |   |                           service-springrest.json
|           |       |   |                           
|           |       |   \---target
|           |       |       \---failsafe-reports
|           |       |               failsafe-summary.xml
|           |       |               
|           |       +---tmp
|           |       \---work
|           \---jkube
|               |   build-buildconfig.yaml
|               |   build-imagestream.yaml
|               |   deployment.yaml
|               |   keystore-secret.yaml
|               |   route.yaml
|               |   run-buildconfig.yaml
|               |   run-imagestream.yaml
|               |   service.yaml
|               |   
|               \---applyJson
|                   \---my-namespace
|                           buildconfig-springrest-build-s2i.json
|                           buildconfig-springrest-run.json
|                           deploymentconfig-springrest.json
|                           route-springrest.json
|                           secret-springrest-keystore-secret.json
|                           service-springrest.json
|                           
\---target
    \---failsafe-reports
            failsafe-summary.xml

This is my fileset for the openshift-maven-plugin step:

<assembly>
	<inline>
		<fileSets>
			<fileSet>
				<directory>${project.basedir}/../../</directory><!-- This is because it is a submodule -->
				<outputDirectory>.</outputDirectory>
			</fileSet>
		</fileSets>
	</inline>
	<name>.</name>
</assembly>

Maybe the .jkube-dockerignore is in the wrong place?

@manusa
Copy link
Member

manusa commented Apr 14, 2021

I haven't checked our code, but I suspect it might have something to do with line separators (could you switch your file from CRLF to LF [if that is the case] and see if it works as expected?)

@manusa manusa moved this from Backlog to Planned in Sprint #200 Apr 14, 2021
@ochstobi
Copy link

@manusa Sadly this ends in the same output.

@manusa
Copy link
Member

manusa commented Apr 14, 2021

Yes, we checked the code and we're using the nio Files helper class to read the file entries.

However, if you're still using the configuration provided in this comment, then the issue has nothing to do with the .jkube-dockerignore. I think that the fact that we're discussing your problem in this issue that is related to the Dockerfile simple mode is misleading us.

In your case, you really need to provide the <excludes> configuration in for your FileSets in the assembly. The .jkube-dockerignore or .jkube-dockerexclude files are only applicable for Dockerfile mode.

@ochstobi
Copy link

@manusa Thanks for this clarification. I apologize for the trouble.

@manusa
Copy link
Member

manusa commented Apr 14, 2021

@manusa Thanks for this clarification. I apologize for the trouble.

OK, no problem. Just confirm to us if once you configure the excludes in your XML config, it works OK.

@ochstobi
Copy link

I have tested it and found out some things. First of all the exclusions are working but not correctly. In the oc:build step the content of <directory>${project.basedir}/../../</directory> is copied completely to the target\docker\springrest-build\build folder. After that the exclusions are deleted. It works for all but .git because this error is thrown:

Failed to execute goal org.eclipse.jkube:openshift-maven-plugin:1.2.0:build (s2i-chained-local) on project springrest.openshift: Failed to execute the build: Unable to create the build archive: C:\springrest\openshift\target\docker\springrest-build\build\.\.git\objects\00\163521cb06fd599fa4f8d74b6c5b81fed9d98d

To dig a bit deeper I deleted the .git folder to see what the exclusions are actually doing.
After copying the resources the exclusions are deleted. Example of the syntax need is below:

<excludes>
    <exclude>**/.git/**</exclude>
    <exclude>/.git/**</exclude>
    <exclude>.git</exclude>
    <exclude>.git/**</exclude>   -- the git stuff is not working because of the error.
    <exclude>**/target</exclude> -- this is applied for all target folders which are not directly in `<directory>${project.basedir}/../../</directory>`
    <exclude>target</exclude>  -- this is applied only for target in `<directory>${project.basedir}/../../</directory>`
    <exclude>target/**</exclude> -- this doesn't do anything at all
    <exclude>**/target/**</exclude> -- this doesn't do anything at all
    <exclude>.idea</exclude>
</excludes>

So exclusions should be prevented from copying to the target. And the syntax for globs should be improved. I would expect that **/target/** excludes all folders named target regardless of the folder depth.

I hope this helps.

@manusa
Copy link
Member

manusa commented Apr 15, 2021

Remember that the syntax for the exclusions is based on FileSystem.html#getPathMatcher.

Since you're on a Windows platform, try using \ instead e.g. **\target\**, or even <exclude>**${file.separator}target${file.separator}**</exclude>

@ochstobi
Copy link

It seems that maven doesn't care. I tried and the results are the same.

@manusa manusa added this to the 1.3.0 milestone May 5, 2021
@manusa manusa added this to Planned in Sprint #201 May 5, 2021
@manusa manusa moved this from Planned to In progress in Sprint #201 May 7, 2021
@manusa manusa self-assigned this May 7, 2021
@manusa
Copy link
Member

manusa commented May 10, 2021

This issue should be fixed after #693

@ochstobi could you please confirm everything works now as expected?

In order to test this I used the following settings with the maven/xml-config quickstart:

  <repositories>
    <repository>
      <id>jitpack.io</id>
      <url>https://jitpack.io</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <id>jitpack.io</id>
      <url>https://jitpack.io</url>
    </pluginRepository>
  </pluginRepositories>
  <!-- ... -->
        <plugins>
          <plugin>
            <groupId>com.github.eclipse.jkube</groupId>
            <artifactId>openshift-maven-plugin</artifactId>
            <version>master-SNAPSHOT</version>
            <configuration>
            <!-- ... -->
                      <fileSet>
                        <directory>${project.basedir}/../../..</directory>
                        <outputDirectory>.</outputDirectory>
                        <excludes>
                          <exclude>.git{/**,}</exclude>
                          <exclude>**/target/**</exclude>
                          <exclude>ide-config{/**,}</exclude>
                          <exclude>.idea{/**,}</exclude>
                          <exclude>.circleci{/**,}</exclude>
                          <exclude>quickstarts{/**,}</exclude>
                        </excludes>
                      </fileSet>
            </configuration>
          </plugin>
        </plugins>

@manusa manusa added the Waiting on feedback Issues that require feedback from User/Other community members label May 10, 2021
@manusa manusa moved this from Review to Done in Sprint #201 May 11, 2021
@ochstobi
Copy link

Where can I get the version "master-SNAPSHOT" to test it? Can't find it in maven central.

@manusa
Copy link
Member

manusa commented May 11, 2021

Just configure the plugin as described in my previous comment.

Note that the Maven GAV coordinates change and that you need to add the Jitpack repository.

@ochstobi
Copy link

Sadly I don't have access to jitpack repository in my environment. So I can only test it after the offical release.

@manusa
Copy link
Member

manusa commented May 11, 2021

Well, you can always clone and install locally 😉

@manusa
Copy link
Member

manusa commented May 18, 2021

We just released 1.3.0, could you please confirm you can no longer reproduce this issue?

@ochstobi
Copy link

@manusa I can confirm that this is working now. Great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Waiting on feedback Issues that require feedback from User/Other community members
Projects
No open projects
Sprint #200
  
Planned
Sprint #201
  
Done
Development

No branches or pull requests

4 participants