Concourse CI + MVN - java

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

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.

[ERROR]: Could not load 'plugins\test.jar' in folder 'plugins'

minecraft paper server error
this is my yml code
api-version: 1.16
commands:
gamestart:
description: start
usage: /gamestart
rule:
description: rule
usage: /rule
main: testgroup.testartifact.Testartifact
name: Testartifact
version: "${project.version}"
Make sure that test.jar exists in the folder and it is valid.

How to download a jar file from ansible

I want to download a jar by using ansible. I want to write a play books to download a jar file.help me out.
How to download a jar file by using ansible code?
This may not be the answer you want.
playbook.yml
---
- hosts: 127.0.0.1
connection: local
tasks:
- name: download jar
get_url:
url: http://ftp.jaist.ac.jp/pub/apache//commons/io/binaries/commons-io-2.6-bin.tar.gz
dest: ./commons-io-2.6-bin.tar.gz
$ ansible-playbook playbook.yml

Gitlab CI for MAVEN project with Docker Image

I have project on java, where i have my tests. Now i have .gitlab-ci.yml:
image: maven:latest
stages:
- build
build:
stage: build
script:
- mvn test-compile compile
tags:
- mytag
only:
refs:
- dev
Each time, when i am making commit in my repo, i am waiting a lot of time, when it will download all depencies. In docker we can use volume option. The question:
Can i download and compile locally this project for creating of .m2 directory, and can i use this directory in my .gitlab-ci.yml. If yes, can you help me how, because i have not found in internet examples according to it.
I made changes in my /etc/gitlab-runner/config.toml:
[runners.docker]
tls_verify = false
image = "maven:latest"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/cache","/M2/.m2:/root/.m2"]
shm_size = 0
/M2/ is a dir, with gitlab-runner owner. But it does not help, how we can see:
Downloaded from central: https://repo.maven.apache.org/maven2/org/hamcrest/hamcrest-parent/1.3/hamcrest-parent-1.3.pom (2.0 kB at 20 kB/s)
Downloading from atlas: https://dl.bintray.com/qameta/maven/org/seleniumhq/selenium/selenium-java/3.8.1/selenium-java-3.8.1.pom
Downloading from nio: http://clojars.org/repo/org/seleniumhq/selenium/selenium-java/3.8.1/selenium-java-3.8.1.pom
Downloading from central: https://repo.maven.apache.org/maven2/org/seleniumhq/selenium/selenium-java/3.8.1/selenium-java-3.8.1.pom
Progress (1): 2.2/5.9 kB
Progress (1): 5.0/5.9 kB
Progress (1): 5.9 kB
steps to take:
(host machine - the machine gitlab - runner installd on and the runner signed)
clone your repository on the host machine
compile it with maven
check that there is cached data folder under /root/.m2 on the host machine
fix your config.toml add this line
volumes = ["/cache","~/.m2:/root/.m2"]
then add to .gitlab-ci.yml
cache:
paths:
- /root/.m2/
variables: MAVEN_OPTS: "-Dmaven.repo.local=.m2"
the .gilatb.yml should look like this
https://stackoverflow.com/a/40024602/4267015
I build a "base docker image". Copy pom.xml to docker image and then run maven verify that image. This is dockerFile:
FROM maven:3.6.1-jdk-8-alpine
COPY pom.xml .
RUN mvn verify clean --fail-never
Open Terminal, then go to the project directory and run docker build:
docker build -t xxx/projectName:base .
Now "base docker image" has cached data.
And then You can use "base docker image" in gitlab-ci.yml:
image: xxx/projectName:base
stages:
- build
build:
stage: build
script:
- mvn test-compile compile
tags:
- mytag
only:
refs:
- dev

is it possible to deploy a simple java web application to a local server using gitlab-ci without docker?

I'm simply trying to copy the war to the webapps folder of my tomcat and restart the server, something like
copy /y .\WebAppFolder\target\WebApp*.war C:\server\webapps\ROOT.war
He can't find this specified path when try to copy, but locally this command works.
My runner is on windows.
The problem is that I was trying to use the "target" created by the previous stage, but the runner deletes everything that is not tracked at the end of each stage.
I add this code in the stage was generate the war so the runner does not destroy the directory
artifacts:
untracked: true
paths:
- WebApp/target
Getting something like that
buildWebApp:maven:
stage: buildWebApp
tags:
- tag
script: mvn clean install -f WebApp/pom.xml
artifacts:
untracked: true
paths:
- WebApp/target
only:
- master
test:
stage: test
tags:
- tag
script:
- copy /y my copy
- mvn test -f testes/pom.xml
only:
- master
Sorry but i lost the link of gitlab doc where i find this solution

Categories

Resources