I'm trying to automatically deploy a simple maven project to AWS lambda using Github, codebuild. When I build the project locally and upload the JAR file to lambda its works fine. However the issue occurs when I try to build the project using codebuild it always fails on a build stage throwing "COMMAND_EXECUTION_ERROR: Error while executing command: mvn package. Reason: exit status 1".
below is my buildspec.yml
version: 0.2
phases:
install:
runtime-versions:
java: corretto11
build:
commands:
- mvn package
- sam package
--template-file template.yml
--s3-bucket iit-cloud
--output-template-file packaged-template.yml
artifacts:
files:
- target/HelloWorld-1.0.jar
enter image description here
Please kindly help me
Related
I build a little rest service to store data in a mongodb atlas db.
Everything is working and I get no errors when I build with ./gradlew clean build.
The project is written in Java 11 and gradle is set to Java 11 too.
But when I try do deploy the app on heroku I get the following error :
-----> Building on the Heroku-20 stack
-----> Determining which buildpack to use for this app
-----> Gradle app detected
-----> Spring Boot detected
-----> Installing **JDK 1.8**... done
-----> Building Gradle app...
-----> executing ./gradlew build -x check
Downloading https://services.gradle.org/distributions/gradle-7.3.2-bin.zip
...........10%...........20%...........30%...........40%...........50%...........60%...........70%...........80%...........90%...........100%
To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.3.2/userguide/gradle_daemon.html#sec:disabling_the_daemon.
Daemon will be stopped at the end of the build
> Task :compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> invalid source release: 11
I added a system.properties to my resources with :
java.runtime.version=11
But it still seems to install java 8.
Can anyone help me on this?
Greetings from Berlin
Nino
here are few steps:
pres ctrl+alt+s and verify your project sdk version
goto root of your project where build.gradle and setting.gradle files are present
here create a new file name system.properties(this file is dettected for deploying Heroku apps to override default propeties)
in this newly created file write this piece of line java.runtime.version=17.0.5 or what ever jdk version you want to deploy with..
update the repo with this file using add.' 'commit' and git push heroku master
thats all :)
I have been trying to get more into the methodology of continuous integration as of recent, and have chosen Travis CI for the job. However, on one of my projects that uses Java and Kotlin my local builds pass, but fail on Travis.
I've been unable to make sense of the error messages that I am getting as to why my build is failing. kotlin-maven-plugin seems to be the origin of the errors. The problematic command as seen in the build logs is mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V.
I have run this command locally with no errors and a successful build.
Here's a relevant snippet of the stack trace from the CI Build Job:
[INFO] --- kotlin-maven-plugin:1.4.32:compile (compile) # BytesToJava ---
[ERROR] java.lang.ExceptionInInitializerError
at com.intellij.pom.java.LanguageLevel.<clinit>(LanguageLevel.java:25)
at com.intellij.core.CoreLanguageLevelProjectExtension.<init>(CoreLanguageLevelProjectExtension.java:26)
at com.intellij.core.JavaCoreProjectEnvironment.<init>(JavaCoreProjectEnvironment.java:42)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreProjectEnvironment.<init>(KotlinCoreProjectEnvironment.kt:26)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$ProjectEnvironment.<init>(KotlinCoreEnvironment.kt:121)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:425)
Would appreciate some resources or even a relevant issue thread. Thanks in advance :)
Travis Build Logs
The problem was being caused by an issue with illegal reflective operations and the Kotlin Maven Plugin with any project over Java 9 (my project uses Java 15). As described by this thread on YouTrack, a workaround is to:
A workaround is to run mvn with the following environment variable: MAVEN_OPTS=--illegal-access=permit
Adding a global environment variable with the same value to my .travis.yml fixed the issue.
I am trying to create a pipeline using Concourse CI using Maven. The pipeline should:
Get the code from git.
Build and run test using maven.
the project generates html report in target folder
above steps are executing properly. The question how to access the output i.e target folder generated by the maven project.
I am not able to access the generated folder and copy to the required folder for later usage.
File pipeline.yml:
resources:
- name: branch-master
type: git
source:
uri: {{git-url}}
branch: master
jobs:
- name: MavenJob
serial: true
plan:
- get: branch-master
trigger: true
- task: mvn-test
privileged: true
file: branch-dev/AppDemo/test.yml
File test.yml:
platform: linux
image_resource:
type: docker-image
source:
repository: maven
tag: latest
inputs:
- name: branch-master
outputs:
- name: mvn-output
run:
path: "mvn"
args: ["-f", "branch-master/AppDemo/pom.xml", "test"]
Please some body help me.
Thanks in advance.
For sake of simplicity and unambiguity I renamed your git repo to project. Let's assume it contains concourse's yamls. And there is a directory AppDemo with java-maven app
project/pipeline.yml:
resources:
- name: project
type: git
source:
uri: {{git-url}}
branch: master
jobs:
- name: MavenJob
serial: true
plan:
- get: project
trigger: true
- task: mvn-test
privileged: true
file: project/test.yml
the job above should locate and trigger the test.yml task
project/test.yml:
platform: linux
image_resource:
type: docker-image
source:
repository: maven # let's hope bin/bash is available there. if no, use sh
tag: latest
inputs:
- name: project # project is your git-repo. all paths are relative to it's location
outputs:
- name: mvn-output
run:
path: /bin/bash
args:
- project/test-script.sh:
project/test-script.sh:
_ROOT=$(pwd)
echo "starting test-script from directory: $ROOT"
cd _ROOT/AppDemo
mvn test
if you want to pass outputs of maven job somewhere further, then you should just copy all those files into mvn-output directory later in the script.
I would also recommend using this bash-script as wrapper rather than raw "maven call" - it's more convenient for debugging the whole process as you can, e.g. echo'ing paths.
in case of any error, if container still alive, try hijacking into it to see what has actually happened there and where files are located:
fly -t <target> hijack -u <url-of-failed-job-from-your-browser>
hope this helps
I have a springboot rest server that I can build with ./gradlew build -x test works fine locally. When I push my master branch to Heroku it fails with the below stack trace.
-----> Gradle app detected
-----> Spring Boot detected
-----> Installing JDK 1.8... done
-----> Building Gradle app...
-----> executing ./gradlew build -x test
Downloading https://services.gradle.org/distributions/gradle-4.10.2-bin.zip
..........................................................................
> Task :compileJava
/tmp/build_20fcdda80fef571f4d65e4396cb813c1/src/main/java/com/edge/riskassesmentwebapp/dto/OnsiteAbandonmentDto.java:10: error: class OnSiteAbandonmentDto is public, should be declared in a file named OnSiteAbandonmentDto.java
... (it repeats the above error for a bunch of classes)
This is my first time deploying a springboot application to Heroku and I'm not sure how to fix the build if it works locally.
try to rename the file OnsiteAbandonmentDto to OnSiteAbandonmentDto.
Note the difference in capitalization
I have the following problem while trying to download the artifact bbb:
[ERROR] Failed to execute goal on project phoenix-model: Could not
resolve dependencies for project
aaa:jar:4.7.0-SNAPSHOT: Failed to
collect dependencies at
bbb:jar:1.0.24-SNAPSHOT: Failed to
read artifact descriptor for
bbb:jar:1.0.24-SNAPSHOT: Could not
transfer artifact
bbb:pom:1.0.24-SNAPSHOT from/to
nexus (https://s.s.com/nexus/content/groups/public):
Hostname 's.s.com' was not verified - [Help 1]
it tries to connect to s.s.com (not the real name) but could not find it in the cacerts keystore since the site doesn't use the name s.s.com in it's certificate but rather s.j.com (and i can't change that since i'm not the admin).
Any way to tell maven or jdk to bypass that?
I am running the command from the eclipse m2 tool plugin by adding the following in the jdk arguments:
-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Djsse.enableSNIExtension=false -Dmaven.wagon.http.ssl.ignore.validity.dates=true
currently using the embeded mvn of kepler which is at 3.2.1
any idea what is wrong?
if i used the same setting with the exception of mvn configured at external version 3.2.2 it runs perfectly fine.