Docker plugin : java.io.FileNotFoundException: /src/main/docker/Dockerfile gradle-docker fails - docker

I'm trying to run spring boot sample on osx (mbp) and I'm getting following exception (Trying buildDocker task). I'm sure I have configured docker properly as I can run command docker-machine run hello-world and receive proper output.
Caused by: java.io.FileNotFoundException: /src/main/docker/Dockerfile (No such file or directory)
at se.transmode.gradle.plugins.docker.image.Dockerfile.fromExternalFile(Dockerfile.groovy:45)
at se.transmode.gradle.plugins.docker.image.Dockerfile$fromExternalFile.call(Unknown Source)
at se.transmode.gradle.plugins.docker.DockerTask.buildDockerfile(DockerTask.groovy:223)
at se.transmode.gradle.plugins.docker.DockerTask.build(DockerTask.groovy:238)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
... 54 more
Other validation would be I can run gradle-docker default build task (i.e. distDocker) without any problem. Problem occur when I try to run build following build task on the gradle script.
// tag::task[]
task buildDocker(type: Docker, dependsOn: build) {
push = true
applicationName = jar.baseName
dockerfile = file('/src/main/docker/Dockerfile')
doFirst {
copy {
from jar
into stageDir
}
}
}
// end::task[]
I can't workout why it cannot determine the file when it's already exists. I tried copying into root and change path for no luck.
OSX : 10.10.4
Java : 1.8

Remove the '/' before src in the path. The path is relative from the current directory (project root) and not the volume root.

Related

Gradle not working inside container but does outside

For some reason gradle is not working for me from w/in a docker container. Of course, outside the container it works fine. What's strange is that it doesn't say what file or directory is missing.
# ./gradlew clean -s
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'foo-bar'.
> Could not resolve com.google.protobuf:protobuf-gradle-plugin:0.8.9.
> Could not get resource 'https://jcenter.bintray.com/com/google/protobuf/protobuf-gradle-plugin/0.8.9/protobuf-gradle-plugin-0.8.9.pom'.
> org.apache.http.ssl.SSLInitializationException: (No such file or directory)
Caused by: java.io.FileNotFoundException: (No such file or directory)
at java.base/java.io.FileInputStream.open0(Native Method)
at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
at org.gradle.internal.resource.transport.http.DefaultSslContextFactory$SslContextCacheLoader.initTrustManagerFactory(DefaultSslContextFactory.java:146)
at org.gradle.internal.resource.transport.http.DefaultSslContextFactory$SslContextCacheLoader.load(DefaultSslContextFactory.java:119)
... 248 more
Appears the problem was that javax.net.ssl.trustStore was being set to blank and overwriting the default, which also explains why FileNotFoundException appeared to not specify a value.

Gradle Docker Fail with ERROR: lstat /var/lib/docker/tmp/buildkit-mount145682111/build/libs: no such file or directory

I am creating simple spring boot application named channelling and trying to build docker image using gradle.
Here is my build.gradle script
plugins {
id 'org.springframework.boot' version '2.2.2.RELEASE'
id 'com.palantir.docker' version '0.25.0'
}
docker {
name "${project.name}:${project.version}"
files 'channeling.jar'
tag 'DockerHub', "test-usr/test:${project.version}"
}
version = '0.0.1-SNAPSHOT'
And this is my Dockerfile
FROM openjdk:8-jdk-alpine
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} channeling.jar
ENTRYPOINT ["java","-jar","/channeling.jar"]
Once I trying to build image using bellow command, It works fine.
docker build -t springio/test .
But when I run gradle docker
It gives bellow error message.
#6 [2/2] COPY build/libs/*.jar channeling.jar
#6 sha256:73a6a8447f65c5bb42b12cceabb3dfa40d4f67e73c569b617331cfdcb9a6a963
#6 ERROR: lstat /var/lib/docker/tmp/buildkit-mount145682111/build/libs: no such file or directory
------
> [2/2] COPY build/libs/*.jar channeling.jar:
------
lstat /var/lib/docker/tmp/buildkit-mount145682111/build/libs: no such file or directory
> Task :channel:docker FAILED
FAILURE: Build failed with an exception
Project structure is like bellow.
I am using bellow gradle and docker versions.
gradle : 6.8
docker : 20.10.2
I searched this issue online but didn't find the solution. Please help to resolve this.
I had a similar issue. I fixed it by avoiding using 'docker' function in Gradle build. Instead I added the following to build.gradle.kts:
configure<com.palantir.gradle.docker.DockerExtension> {
dependsOn(tasks.findByPath("build"))
name = "${project.name}:${version}"
files("build/libs/${project.name}-${version}.jar")
buildArgs(mapOf("JAR_FILE" to "${project.name}-${version}.jar"))
}
Also, make sure you put dependsOn function, as it has to execute after build.

How to Setup Sonarcube scanner for Xcode/Objective-C iOS Project

I am new to SonarQube. I find the documents given in the portal has very less information about setting it up in Xcode/Objective-C. Can anyone help in instructions for Setting/Installing sonarQube scanner.
I use this below steps for Android project. I need the steps for iOS which I am not able to find
1. Copy sonar cube from LS Path : \\ipaddress\Mobility\LS\Tools\Sonar
2. Paste it in C:\Program Files (x86)\
3. Run sonar-runner
4. Set Environment variable path: C:\Program Files (x86)\sonar-runner-2.4\bin
5. Configure Project : Example :
sonar.projectName=
sonar.projectKey=
sonar.host.url=
sonar.sources=app/src/main/java/
sonar.login=
sonar.password=
sonar.projectVersion=
in sonar-project file.
6. Paste that file inside our project folder
7. Open command prompt and go to projectso path.
7. copy paste the following in command prompt:
sonar-scanner -Dsonar.sources=app/src -Dsonar.java.binaries=app/build/outputs/apk -Dsonar.java.libraries=app/libs/*.jar
I am getting the below error
ERROR: Error during SonarQube Scanner execution
org.sonarsource.scanner.api.internal.ScannerException: Unable to
execute SonarQube at
org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:84)
at
org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:71)
at java.base/java.security.AccessController.doPrivileged(Native
Method) at
org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:71)
at
org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:67)
at
org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:218)
at
org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:156)
at org.sonarsource.scanner.cli.Main.execute(Main.java:74) at
org.sonarsource.scanner.cli.Main.main(Main.java:61) Caused by:
java.lang.IllegalStateException: Fail to get bootstrap index from
server at
org.sonarsource.scanner.api.internal.Jars.getBootstrapIndex(Jars.java:100)
at
org.sonarsource.scanner.api.internal.Jars.getScannerEngineFiles(Jars.java:76)
at org.sonarsource.scanner.api.internal.Jars.download(Jars.java:70)
at
org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:39)
at
org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:75)
... 8 more Caused by: java.lang.IllegalStateException: Status
returned by url [http://ipaddress/batch/index] is not valid:
[407] at
org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerConnection.java:115)
at
org.sonarsource.scanner.api.internal.ServerConnection.downloadString(ServerConnection.java:98)
at
org.sonarsource.scanner.api.internal.Jars.getBootstrapIndex(Jars.java:96)
... 12 more ERROR:

Custom Ant Task Not Working On Build Server

I've got a custom Ant task that I'm using successfully from gradle on my local machine:
task fetchRelMod {
doLast {
println 'Fetching the RelMod'
ant.taskdef(name:'relmod',
classpath:'retrievePBSInfo.jar:hsjt400-4-9.jar',
classname:"com.myco.ant.tasks.RetrievePBSRelModString")
ant.relmod(user:project.ext.props.getProperty('fetchrelmod.username'),
password:project.ext.props.getProperty('fetchrelmod.password'),
prodCode:project.ext.props.getProperty('profile.pbs.product.code'),
branch:project.ext.props.getProperty('profile.pbs.branch'),
state:project.ext.props.getProperty('profile.pbs.relmod.selector'))
project.ext.set('iseries_relmod',ant.relmodStub)
project.ext.set('iseries_relmodAndDate', ant.relmod)
}
}
I've got the jar files sitting next to build.gradle for now, out of simplicity... they exist in the same location on the build server. Works great locally. When I run my build from my build server (either through Jenkins or going on the box and running Gradle directly), I get the following:
sudo /var/lib/jenkins/tools/hudson.plugins.gradle.GradleInstallation/gradle214/bin/gradle all -DisQUABuild=true
Building My App
Loading Properties files...
QUA Build. Using build-qua.props
:fetchRelMod
Fetching the RelMod
:fetchRelMod FAILED
FAILURE: Build failed with an exception.
* Where:
Build file '/var/lib/jenkins/workspace/MyApp/build.gradle' line: 141
* What went wrong:
Execution failed for task ':fetchRelMod'.
> taskdef class com.myco.ant.tasks.RetrievePBSRelModString cannot be found
using the classloader AntClassLoader[/var/lib/jenkins/workspace/myApp/hsjt400-4-9.jar]
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 3.104 secs
What concerns me is that there are two jar files in the classpath and it only mentions one in the error. Does anyone have any ideas as to what might be going on?

Unable to run the demo setup

I have downloaded the Activity 5.10 zip file and then i have downloaded and configured the Apache ANT and i test it and it worked successfully.
But i am unable to run the demo file as specified in this link http://activiti.org/userguide/#demo.setup
if i type the following using the cmd command line:-
C:\activiti-5.10\activiti-5.10\setup>ant demo.start
I will get the following error:-
'ant' is not recognized as an internal or external command, operable program or batch file.
Can anyone help me in identifying what is the problem?
BR
:::UPDATE:::
thanks for the reply, i have copied the ANT bin files inside the setup directory for the activity,, then i run the CMD command again ,, but i got the following error that i build failed,,
AS MENTIONED BELOW:-
C:\Users\Desktop\activiti-5.10\activiti-5.10\setup>ant demo.start
Buildfile: C:\Users\Desktop\activiti-5.10\activiti-5.10\setup\build.xml
demo.install:
internal.cfg.create:
[copy] Copying 1 file to C:\Users\Desktop\activiti-5.10\activiti-5.
10\setup\build\activiti-cfg
[zip] Building zip: C:\Users\Desktop\activiti-5.10\activiti-5.10\s
etup\build\activiti-cfg.jar
[echo] copying configuration to ../workspace/activiti-engine-examples/src/m
ain/config
[unzip] Expanding: C:\Users\Desktop\activiti-5.10\activiti-5.10\setu
p\build\activiti-cfg.jar into C:\Users\Desktop\activiti-5.10\activiti-5.
10\workspace\activiti-engine-examples\src\main\config
internal.classpath.libs:
internal.taskdef.launch:
h2.start:
[echo] starting H2 database...
[launch] launching cmd 'C:\Users\Desktop\activiti-5.10\activiti-5.10\
apps\h2\h2.start.bat ' in dir 'C:\Users\Desktop\activiti-5.10\activiti-5
.10\apps\h2'
[launch] waiting for launch completion msg 'TCP server running'...
[launch] 'java' is not recognized as an internal or external command,
[launch] operable program or batch file.
[launch] launched process completed
[echo] H2 database started
tomcat.start:
BUILD FAILED
C:\Users\Desktop\activiti-5.10\activiti-5.10\setup\build.xml:330: couldn
't find executable for script C:\Users\Desktop\activiti-5.10\activiti-5.
10\apps\apache-tomcat-6.0.32\bin\startup
Total time: 0 seconds
Looks like you didn't set the ant directory in you path variable. Either specifiy the entire path to ant or add it to the path variable
I typed tomcat.install and it solved the problem since I need to download the tomcat inside the apps directory.

Resources