Action failed: gradle dependencies CircleCi - java

I have integrated CircleCI to run Espresso test on my app. I have taken the following circle.yml file from another online github repo and changed the android build tools and android version to 25. However when I run the build on the circleCI server, I get the following error. I have granted the execution permission in yml file.
My app Repo structure is
Action failed: gradle dependencies
export TERM="dumb"
if [ -e ./gradlew ]; then ./gradlew dependencies;else gradle dependencies;fi
bash: line 2: ./gradlew: Permission denied
export TERM="dumb"
if [ -e ./gradlew ]; then ./gradlew dependencies;else gradle dependencies;fi
returned exit code 126
Action failed: gradle dependencies
circle.yml:
general:
artifacts:
- /home/ubuntu/MyRideApp/app/build/outputs/apk/
machine:
environment:
ANDROID_HOME: /usr/local/android-sdk-linux
ADB_INSTALL_TIMEOUT: 240
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx3072M -XX:+HeapDumpOnOutOfMemoryError"'
dependencies:
pre:
- chmod +x gradlew
- touch app/google-services.json
- echo y | android update sdk --no-ui --all --filter "tools,android-25,build-tools-25.0.2,platform-tools,extra-android-m2repository,extra-android-support,extra-google-m2repository,extra-google-google_play_services"
cache_directories:
- /usr/local/android-sdk-linux/tools
- /usr/local/android-sdk-linux/build-tools/25.0.2
override:
- ANDROID_HOME=/usr/local/android-sdk-linux ./gradlew dependencies
# Comment the test stuff out (or remove it) if you don't need it.
test:
pre:
- emulator -avd circleci-android23 -no-audio -no-window:
background: true
parallel: true
- circle-android wait-for-boot
# unlock emulator
- sleep 30
- adb shell input keyevent 82
override:
# - ./gradlew clean assemble
# This will run the tests:
- ./gradlew assemble connectedDebugAndroidTest -PdisablePreDex --console=plain --info
post:
- cp -r app/build/outputs $CIRCLE_ARTIFACTS
- cp -r app/build/outputs/androidTest-results/connected/ $CIRCLE_TEST_REPORTS
gradle/wrapper/gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
/gradle/wrapper does contain gradle-wrapper.jar

A solution is on the circleCI forum.
You have to add execution right like the following : chmod +x gradlew
It works for me.
Here is an example of my circleci.yml :
machine:
java:
version: oraclejdk8
dependencies:
override:
- chmod +x gradlew
- ./gradlew dependencies
test:
override:
- chmod +x grailsw
- ./grailsw test-app --non-interactive
post:
- mkdir -p $CIRCLE_TEST_REPORTS/junit/
- find . -type f -regex ".*/target/test-reports/.*xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;

Related

Build Flatpak from Java application

I'm currently working on DXVKoTool, a Compose application built with Kotlin.
As I want it to be easily available on the Steam Deck, I try to build a Flatpak off it.
Basically what I wanted to do is packaging it (with jpackage) and use the built binaries when building the Flatpak.
My building process would look like this:
./gradlew packageAppImage
flatpak-builder build/release/main/flatpak dev.datlag.DXVKoTool.yml --force-clean
The packageAppImage command produces an output like this:
{project-dir}
|-build
|-release
|-main
|-app
|-DXVKoTool
|-bin
| |-DXVKoTool {executable}
|-lib
|-{resources, binaries, etc.}
However building the Flatpak is somehow driving me crazy and I'm not sure what's wrong.
My flatpak build YAML file:
app-id: dev.datlag.DXVKoTool
runtime: org.freedesktop.Platform
runtime-version: '21.08'
sdk: org.freedesktop.Sdk
command: DXVKoTool
modules:
- name: dxvkotool
buildsystem: simple
build-commands:
- mkdir -p /app/lib/
- install -Dm755 ./build/release/main/app/DXVKoTool/bin/DXVKoTool /app/bin/DXVKKoTool
- cp -R ./build/release/main/app/DXVKoTool/lib/* /app/lib/
sources:
- type: file
path: ./build/release/main/app/DXVKoTool/bin/DXVKoTool
- type: dir
path: ./build/release/main/app/DXVKoTool/lib/
When I run the flatpak-builder command, it's stopping with the following error:
Emptying app dir 'build/release/main/flatpak'
Downloading sources
Starting build of dev.datlag.DXVKoTool
Cache hit for openjdk, skipping build
Cache miss, checking out last cache hit
========================================================================
Building module git in /home/jeff/Projects/Multiplatform/DXVKoTool/.flatpak-builder/build/git-1
========================================================================
Running: mkdir -p /app/lib/
Running: install -Dm755 ./build/release/main/app/DXVKoTool/bin/DXVKoTool /app/bin/DXVKoTool
install: cannot stat './build/release/main/app/DXVKoTool/bin/DXVKoTool': No such file or directory
When I change the config to the following:
app-id: dev.datlag.DXVKoTool
runtime: org.freedesktop.Platform
runtime-version: '21.08'
sdk: org.freedesktop.Sdk
command: DXVKoTool
modules:
- name: dxvkotool
buildsystem: simple
build-commands:
- mkdir -p /app/lib/
- install -Dm755 DXVKoTool /app/bin/DXVKoTool
- cp -R lib/* /app/lib/
sources:
- type: file
path: ./build/release/main/app/DXVKoTool/bin/DXVKoTool
- type: dir
path: ./build/release/main/app/DXVKoTool/
The building works but after installing the outcome it doesn't start with this error:
bwrap: execvp DXVKoTool: No such file or directory
Would be nice if someone can help me building the Flatpak.

Gitlab CI/CD running fine on local but not on gitlab

I am trying to build a gitlab CI/CD pipeline on my java maven project. I tried all the stages on my local machine and they are passing successfully but when I try the same things on gitlab repo it is throwing error. I tried almost every solution and gone through numerous posts to resolve the errors but to no use. Here is my yml content:
image: maven:3.5-jdk-8
variables:
MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
include:
- template: Security/SAST.gitlab-ci.yml
cache:
paths:
- .m2/settings.xml
# Define stages
# Stages group various steps into one block,
# if any step fails, the entire stage fails
stages:
- validate
- compile
- SonarQube
- test
validate:
stage: validate
script:
- mvn validate
compile:
stage: compile
script:
- mvn $MAVEN_CLI_OPTS compile
sonarqube-check:
image: maven:3.6.3-jdk-11
stage: SonarQube
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
script:
- mvn sonar:sonar \ -Dsonar.projectKey=XX.XX.XXX.XXX \ -Dsonar.host.url=http://XX.XX.XXX.XXX \ -Dsonar.login=XX.XX.XXX.XXX -X
allow_failure: true
spotbugs-sast:
variables:
COMPILE: "false"
SECURE_LOG_LEVEL: "debug"
artifacts:
reports:
sast: gl-sast-report.json
#spotbugs-sast:
# variables:
# SECURE_LOG_LEVEL: "debug"
#FAIL_NEVER: 1
test:
stage: test
script:
- mvn $MAVEN_CLI_OPTS test -B
The stage validate and compile are running fine but I am getting warnings in sonar check and spotbugs sast. The same is running fine on my local.
In the sonarqube check the error is:
Error resolving version for plugin ' -Dsonar.host.url=http://XX.XX.XXX.XXX' from the repositories [local (/builds/XX.XX.XXX.XXX/.m2/repository), central (https://repo.maven.apache.org/maven2)]: Plugin not found in any plugin repository -> [Help 1]
org.apache.maven.plugin.version.PluginVersionResolutionException: Error resolving version for plugin ' -Dsonar.host.url=http://XX.XX.XXX.XXX' from the repositories [local (/builds/XXXX/XXXXX/.m2/repository), central (https://repo.maven.apache.org/maven2)]: Plugin not found in any plugin repository
and for the spotbugs-sast warning the error is:
[FATA] [Find Security Bugs] ▶ lstat /root/.m2/repository: no such file or directory
I have spent numerous hours resolving this and waiting for the project to compile successfully with all the stages but every time I was disappointed. Please help. I appreciate your time.
Maven recognized the String -Dsonar.host.url=http://XX.XX.XXX.XXX as a plugin/goal that it needs to resolve.
This is caused by the \ in your script.
Instead of:
mvn sonar:sonar \ -Dsonar.projectKey=XX.XX.XXX.XXX \ -Dsonar.host.url=http://XX.XX.XXX.XXX \ -Dsonar.login=XX.XX.XXX.XXX -X
try:
mvn sonar:sonar -Dsonar.projectKey=XX.XX.XXX.XXX -Dsonar.host.url=http://XX.XX.XXX.XXX -Dsonar.login=XX.XX.XXX.XXX -X
I assume that you copied that command from a format like this:
mvn sonar:sonar \
-Dsonar.projectKey=XX.XX.XXX.XXX \
-Dsonar.host.url=http://XX.XX.XXX.XXX \
-Dsonar.login=XX.XX.XXX.XXX -X
In bash the \ must be at the end of the line if the command contains a linebreak so it's recognized as one command.
But you need to remove it if you convert it to one line.

hyperledger fabric2.2.1, when I install the chaincode from asset-transfer-basic/chaincode-java, I failed ! why?

fabric2.2.1, when I install the chaincode from asset-transfer-basic/chaincode-java, I failed ! why?
and why the docs for v2.2.1 don't have the java tutorials?? please help me to figure out,thanks!!
Here are the code errors I encountered :
cyj#cyj-ubuntu:~/go/src/fabric-samples/test-network$ peer lifecycle chaincode package basic.tar.gz --path ../asset-transfer-basic/chaincode-java/ --lang java --label basic_1.0
cyj#cyj-ubuntu:~/go/src/fabric-samples/test-network$ peer lifecycle chaincode install basic.tar.gz
Error: chaincode install failed with status: 500 - failed to invoke backing implementation of 'InstallChaincode': could not build chaincode: docker build failed: docker image build failed: docker build failed: Error returned from build: 1 "+ INPUT_DIR=/chaincode/input
OUTPUT_DIR=/chaincode/output
++ mktemp -d
TMP_DIR=/tmp/tmp.faBNpJ
++ find /chaincode/input -name .jar
++ paste -s -d : -
JARS=
++ find /chaincode/input -name '*.jar'
++ wc -l
NUM_JARS=1
for DIR in ${INPUT_DIR} ${INPUT_DIR}/src
'[' -f /chaincode/input/build.gradle -o -f /chaincode/input/build.gradle.kts ']'
'[' -f /chaincode/input/pom.xml ']'
for DIR in ${INPUT_DIR} ${INPUT_DIR}/src
'[' -f /chaincode/input/src/build.gradle -o -f /chaincode/input/src/build.gradle.kts ']'
buildGradle /chaincode/input/src /chaincode/output
echo 'Copying from /chaincode/input/src to /tmp/tmp.faBNpJ'
Copying from /chaincode/input/src to /tmp/tmp.faBNpJ
cd /chaincode/input/src
tar cf - .
cd /tmp/tmp.faBNpJ
tar xf -
cd /tmp/tmp.faBNpJ
echo 'Gradle build'
Gradle build
'[' -f ./gradlew ']'
chmod +x ./gradlew
./gradlew build shadowJar -x test
Downloading https://services.gradle.org/distributions/gradle-6.5.1-bin.zip
.................................................................................................
Welcome to Gradle 6.5.1!
Here are the highlights of this release:
Experimental file-system watching
Improved version ordering
New samples
For more details see https://docs.gradle.org/6.5.1/release-notes.html
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
What went wrong:
Task 'shadowJar' not found in root project 'basic'.
Try:
Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 45s
"

Docker gradle access denied

i tried to build docker image using docker-compose but i got this error
/bin/sh: 1: ./gradle: Permission denied
my Dockerfile is
FROM gradle:6.5.0-jdk11 AS TEMP_BUILD_IMAGE
ENV APP_HOME=/usr/app/
WORKDIR $APP_HOME
COPY build.gradle.kts settings.gradle.kts $APP_HOME
COPY gradle $APP_HOME/gradle
COPY --chown=gradle:gradle . /home/gradle/src
USER root
RUN chown -R gradle /home/gradle/src
RUN ./gradle build || return 0
COPY . .
RUN ./gradle clean build
FROM openjdk:11-jdk
ENV ARTIFACT_NAME=app.jar
ENV APP_HOME=/usr/app/
WORKDIR $APP_HOME
COPY --from=TEMP_BUILD_IMAGE $APP_HOME/build/libs/$ARTIFACT_NAME .
ENTRYPOINT exec java -jar ${ARTIFACT_NAME}
and this is what i got in the shell
D:\Docker>docker-compose up -d
Building config-server
Step 1/17 : FROM gradle:6.5.0-jdk11 AS TEMP_BUILD_IMAGE
---> a001e5b2850a
Step 2/17 : ENV APP_HOME=/usr/app/
---> Using cache
---> 07cf3a267c37
Step 3/17 : WORKDIR $APP_HOME
---> Using cache
---> 87be3841245e
Step 4/17 : COPY build.gradle.kts settings.gradle.kts $APP_HOME
---> Using cache
---> eff11fa2348e
Step 5/17 : COPY gradle $APP_HOME/gradle
---> Using cache
---> 10fca093f82e
Step 6/17 : COPY --chown=gradle:gradle . /home/gradle/src
---> b1f888f97818
Step 7/17 : USER root
---> Running in bde4f2d435fe
Removing intermediate container bde4f2d435fe
---> e8fba435db0c
Step 8/17 : RUN chown -R gradle /home/gradle/src
---> Running in d88ea2196f38
Removing intermediate container d88ea2196f38
---> b5b4727dd51f
Step 9/17 : RUN ./gradle build || return 0
---> Running in d218205301d9
/bin/sh: 1: ./gradle: Permission denied
Removing intermediate container d218205301d9
---> da37b296879b
Step 10/17 : COPY . .
---> e6cfac4a75a3
Step 11/17 : RUN ./gradle clean build
---> Running in 34480bf73106
/bin/sh: 1: ./gradle: Permission denied
ERROR: Service 'config-server' failed to build: The command '/bin/sh -c ./gradle clean build' returned a non-zero code: 126
how can i solve this error please?
You are using a base image which has gradle by itself. So, you don't need to copy gradle explicitly. Just remove ./ from gradle RUN.
RUN gradle build || return 0
COPY . .
RUN gradle clean build
Output
Step 9/17 : RUN gradle build || return 0
---> Running in fd470c45e443
Welcome to Gradle 6.5!
Here are the highlights of this release:
- Experimental file-system watching
- Improved version ordering
- New samples
For more details see https://docs.gradle.org/6.5/release-notes.html
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :buildEnvironment
------------------------------------------------------------
Root project
------------------------------------------------------------
classpath
No dependencies
A web-based, searchable dependency report is available by adding the --scan option.
BUILD SUCCESSFUL in 25s
1 actionable task: 1 executed
Removing intermediate container fd470c45e443
---> dd4056a53129
Step 10/17 : COPY . .
---> 3a46c7e9d9bb
Step 11/17 : RUN gradle clean build
---> Running in c3341e91aef0
Welcome to Gradle 6.5!

Travis CI Android build keep failing with gradlew no such file

my travis ci build keeps failing with,
$ chmod +x /.gradlew
chmod: cannot access ‘/.gradlew’: No such file or directory
The command "chmod +x /.gradlew" failed and exited with 1 during .
I tried all the suggestions, different yml files but cant get rid of this error.
My travis yml is on root directory, the here is my folder structure
root: /src .gitignore .travis.yml
src: /client /server
client: /app /gradle/wrapper build.gradle gradle.properties gradlew gradlew.bat settings.gradle
Here is my travis.yml
sudo: false
language: android
jdk:
- oraclejdk8
android:
components:
- tools
- platform-tools
- tools
# The BuildTools version used by your project
- build-tools-25.0.3
# The SDK version used to compile your project
- android-25
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
- addon-google_apis-google-19
before_install:
- chmod +x /.gradlew
script:
- "/.gradlew clean build"
notifications:
email: false
and here is my build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://maven.google.com" }
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3.3'
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Any suggestions? Thanks
To debug this you could change the before_install section to print current directory and list its contents.
before_install:
- pwd
- ls -la
- chmod +x /.gradlew
Add this .yml file
- name: Check Directory
run: - pwd
- ls -la
- cd android && chmod +x ./gradlew
- name: Build Command
run: cd android && chmod +x ./gradlew

Categories

Resources