I have a react project that I configured on Gitlab CICD Pipeline (with docker).
In my pipeline, I have a step for create the package that use frontend-maven-plugin plugin (Packaging)
Each time I run the pipeline all artifact are download. I want to use a cache in the pipeline but the configuration below doesn't work. I think that frontend-maven-plugin use a different location for cache.
How can I configure it ?
The pipeline Gitlab :
stages:
- build
- analyse
- package
- deploiement
cache:
paths:
- project_front/projectdir/node_modules/
variables:
MAVEN_CLI_OPTS: "-s ${MAVEN_PROJECT_SETTINGS} --batch-mode"
MAVEN_OPTS: "-Dmaven.repo.local=${MAVEN_PROJECT_REPO}"
#
# Build de l'application
Build:
image: maven:3.5.2-jdk-8
stage: build
tags: [ 'project' ]
script:
# Récupération de la version du projet maven
- mvn $MAVEN_CLI_OPTS -U clean install -D maven.test.skip=true
#
# Step d'analyse SONAR
Qualimétrie:
image: maven:3.5.2-jdk-8
stage: analyse
tags: [ 'project' ]
script:
- mvn $MAVEN_CLI_OPTS -P sonarqubeproject,jacoco,nexus -U -D sonar.qualitygate.wait=true -D sonar.branch.name=$CI_COMMIT_BRANCH verify sonar:sonar
artifacts:
when: always
reports:
junit:
- "*/target/surefire-reports/TEST-*.xml"
#
# Génération du package de livraison
Packaging:
image: maven:3.5.2-jdk-8
stage: package
tags: [ 'project' ]
script:
# Packaging
- mvn $MAVEN_CLI_OPTS -P package_livraison -U package -Dmaven.test.skip=true -D HTTP_PROXY=${PROXY_SRV} -D HTTPS_PROXY=${PROXY_SRV}
artifacts:
paths:
- '**/target/*.tar.gz'
#
# Step de déploiement Ansible
Deploiement INT:
stage: deploiement
tags: [ 'project' ]
image: ansible/centos7-ansible
only:
- master
- develop
- feature-gitlab-cicd
when: manual
dependencies:
- Packaging
script:
#Installation de XMLLINT pour récupérer la version dans le POM
- yum -y install libxml2
# Récupération de la version du projet maven
- VERSION_PROJECT=`xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' pom.xml`
# Execution du ssh-agent
- eval $(ssh-agent -s)
# Récupération de la clé privée de l'hote et envoi dans le container
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
# Création des répertoires
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
# Recherche de l'hote
- ssh-keyscan myhost >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
# Envoi du package à la machine PROJECT
- cp project_deploiement/target/*.tar.gz /home/gitlab-runner/depot/
#Lancement du playbook
- ansible-playbook -v -i project_ansible/project-hosts project_ansible/ansible/project-install-playbook-int.yml -f 10 --extra-vars "project_version=${VERSION_PROJECT} -vvvv"
profile :
<profile>
<id>package_livraison</id>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>${frontend-maven-plugin.version}</version>
<configuration>
<nodeVersion>${node.version}</nodeVersion>
<yarnVersion>${yarn.version}</yarnVersion>
<workingDirectory>${frontend-src-dir}</workingDirectory>
<installDirectory>${project.build.directory}</installDirectory>
</configuration>
<executions>
<execution>
<id>install-frontend-tools</id>
<goals>
<goal>install-node-and-yarn</goal>
</goals>
</execution>
<execution>
<id>yarn-install</id>
<goals>
<goal>yarn</goal>
</goals>
<configuration>
<!-- Le proxy maven n'est pas utilisé, on le redéfinit-->
<yarnInheritsProxyConfigFromMaven>true</yarnInheritsProxyConfigFromMaven>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>build-frontend</id>
<goals>
<goal>yarn</goal>
</goals>
<phase>prepare-package</phase>
<configuration>
<arguments>build</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Properties :
<properties>
<frontend-src-dir>./projectdir</frontend-src-dir>
<node.version>v10.15.3</node.version>
<yarn.version>v1.15.2</yarn.version>
<frontend-maven-plugin.version>1.7.6</frontend-maven-plugin.version>
</properties>
The directory Structure
Related
I maintain a few Java library projects on GitLab, which I build with a GitLab CI workflow and currently deploy to a GitLab Maven repository. Now I would like to deploy them to Maven Central instead, but have been unable to find any tutorials, examples or boilerplate code for doing so.
My current .gitlab-ci.yml looks like this:
Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
image: maven:3.6.3-openjdk-8
cache:
key: "$CI_JOB_NAME"
paths:
- .m2/repository
- public
.verify: &verify
stage: test
script:
- 'mvn $MAVEN_CLI_OPTS verify'
except:
- master
- dev
verify:jdk8:
<<: *verify
# Deploy to GitLab's Maven Repository for `master` and `dev` branch
deploy:jdk8:
stage: deploy
script:
- if [ ! -f ci_settings.xml ];
then echo "CI settings missing\! If deploying to GitLab Maven Repository, please see https://docs.gitlab.com/ee/user/project/packages/maven_repository.html#creating-maven-packages-with-gitlab-cicd for instructions.";
fi
- 'mvn $MAVEN_CLI_OPTS deploy -s ci_settings.xml'
only:
- master
- dev
# Deploy Javadoc to GitLab Pages
pages:
stage: deploy
script:
- 'mvn javadoc:javadoc -DadditionalJOption=-Xdoclint:none'
- if [ -e public/javadoc/$CI_COMMIT_REF_NAME ];
then rm -Rf public/javadoc/$CI_COMMIT_REF_NAME ;
fi
- 'mkdir -p public/javadoc/$CI_COMMIT_REF_NAME'
- 'cp -r target/site/apidocs/* public/javadoc/$CI_COMMIT_REF_NAME/'
artifacts:
paths:
- public
only:
- master
- dev
The closest I found was an instruction on deploying to Artifactory, but nothing about Maven Central. What is the procedure for Maven Central?
I have two projects:
devops/deploy/landing and frontend/landing.
The gitlab-ci.yml file is stored in devops/deploy/landing, and everything works fine there.
But when I add this file to the CI frontend/landing settings the external gitlab-ci.yml: .gitlab-ci.yml#devops/deploy/landing build process starts, but it writes that there are no available runners, although the same runner as for devops/deploy/landing is added to frontend/landing.
GitLab version - 13.4.3
gitlab-ci.yml
stages:
- build
- deploy
build_node:
stage: build
script:
- docker login $DOCKER_REGISTRY -u $DOCKER_USER -p $DOCKER_PASSWORD
- git clone https://$GIT_USER:$GIT_TOKEN#gitlab.domain.dev/frontend/landing.git
- docker build --network host -t $DOCKER_REGISTRY/landing:$VERSION . -f Dockerfile
- docker push $DOCKER_REGISTRY/landing:$VERSION
- docker image rm $DOCKER_REGISTRY/landing:$VERSION
- docker logout $DOCKER_REGISTRY
only:
- master
deploy_dev1:
image: ubuntu:latest
stage: deploy
script:
- apt update && apt install openssh-client -y
- eval $(ssh-agent -s) && ssh-add <(echo "$SSH_PRIVATE_KEY_DEV" | base64 --decode)
- ssh -o StrictHostKeyChecking=no root#$IP_DEV1 /home/deploy/deploy.sh
only:
- master
Runner Configuration
Added projects
Introduction
I want that my Maven project(s) documentation (site) gets deployed at the docs folder of my website.
I'm using Apache Maven Wagon SSH at the moment to get the job done. The SSH connection works great, It pushes a zip file to the host and unpack's it.
I'm using fake names in these examples; provider.com, company.com and company
Problem
But the unpacking is placed in the wrong folder...
Instead it steps through the dirs; /domains/company.com/htdocs/docs/ and create these folders to put the documentation in: /${project.slug}/${project.artifactId}/${project.version}
It makes a new directory from the root: r.com/domains/company.com/htdocs/docs/${project.slug}/${project.artifactId}/${project.version}
Question
How can I manage the SSH/SCP to connect scp:ssh.provider.com, than walk through /domains/company.com/htdocs/docs/ directories and finally create the directories /${project.slug}/${project.artifactId}/${project.version} with the documentation inside?
Apendix. Files
Log
: scp:ssh.provider.com/domains/company.com/htdocs/docs/company/company-parent/1-SNAPSHOT/docs/ - Session: Opened
[INFO] Pushing C:\Users\nberl\Code\company\company-maven-parent\target\site
[INFO] >>> to scp:ssh.provider.com/domains/company.com/htdocs/docs/company/company-parent/1-SNAPSHOT/./
Executing command: mkdir -p "r.com/domains/company.com/htdocs/docs/company/company-parent/1-SNAPSHOT/./"
Executing command: mkdir -p "r.com/domains/company.com/htdocs/docs/company/company-parent/1-SNAPSHOT/."
Executing command: scp -t "r.com/domains/company.com/htdocs/docs/company/company-parent/1-SNAPSHOT/./wagon4192311672559342478.zip"
Uploading: ./wagon4192311672559342478.zip to scp:ssh.provider.com/domains/company.com/htdocs/docs/company/company-parent/1-SNAPSHOT/
##########
Transfer finished. 40802 bytes copied in 0.064 seconds
Executing command: cd "r.com/domains/company.com/htdocs/docs/company/company-parent/1-SNAPSHOT/./"; unzip -q -o "wagon4192311672559342478.zip"; rm -f "wagon4192311672559342478.zip"
Executing command: chmod -Rf g+w,a+rX r.com/domains/company.com/htdocs/docs/company/company-parent/1-SNAPSHOT/
scp:ssh.provider.com/domains/company.com/htdocs/docs/company/company-parent/1-SNAPSHOT/ - Session: Disconnecting
scp:ssh.provider.com/domains/company.com/htdocs/docs/company/company-parent/1-SNAPSHOT/ - Session: Disconnected
POM configuration
The distribution management of the site:
<distributionManagement>
<site>
<id>company-docs</id>
<name>Company Docs</name>
<url>scp:ssh.provider.com/domains/company.com/htdocs/docs/${project.slug}/${project.artifactId}/${project.version}/docs</url>
</site>
</distributionManagement>
The site deploy profile:
<profile>
<id>deploy-site</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.7</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>site-deploy</id>
<phase>site</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Well after some research and a lot of just trying I found finally the solution!
In the distribution management sector you have to describe the absolute path from the absolute root of the server to the url.
Also you should use scp:// and end the domain with : (see the example below).
<distributionManagement>
<site>
<id>company-docs</id>
<name>Company Docs</name>
<url>scp://ssh.provider.com:/home/user/domains/company.com/htdocs/docs/${project.slug}/${project.artifactId}/${project.version}/docs</url>
</site>
</distributionManagement>
Now everything works like a charm!
I use circle to run JS and PHP test (Protractor/ Phpunit).
I would like use parallelism to win time but i don't know configure the parallelism. I activate the parallelism in the circle parameters (2 containers).
My actual circle configuration (circle.yml) :
# Depend de app/config/parameters.circle.yml (parametre symfony pour circle) et app/config/apache.circle (configuration d'Apache pour Circle)
# Configuration du serveur
machine:
php:
version: 5.4.21
timezone:
Europe/Paris
hosts:
bluegrey.circle.dev: 127.0.0.1
dependencies:
pre:
# SauceConnect (Angular)
- wget https://saucelabs.com/downloads/sc-latest-linux.tar.gz
- tar -xzf sc-latest-linux.tar.gz
- ./bin/sc -u johnnyEvo -k xxx:
background: true
pwd: sc-*-linux
# Installation protractor (Angular)
- npm install -g protractor
# On active XDebug
- sed -i 's/^;//' ~/.phpenv/versions/$(phpenv global)/etc/conf.d/xdebug.ini
- echo "xdebug.max_nesting_level = 250" > ~/.phpenv/versions/$(phpenv global)/etc/conf.d/xdebug.ini
# Configuration d'Apache
- cp app/config/apache.circle /etc/apache2/sites-available
- a2ensite apache.circle
- sudo service apache2 restart
override:
# Composer
- composer install --prefer-source --no-interaction
post:
# Assets
- app/console assetic:dump
# Parameters
- cp app/config/parameters.circle.yml.dist app/config/parameters.yml
database:
pre:
# Base de données (test)
- app/console doctrine:database:create --env=test --no-interaction
- app/console doctrine:schema:update --force --env=test --no-interaction
# Base de données (prod/ angular)
- app/console doctrine:database:drop --no-interaction --force
- app/console doctrine:database:create --no-interaction
- app/console doctrine:schema:update --force --no-interaction
# Fixture
- app/console doctrine:fixture:load --no-interaction
test:
pre:
# Permission pour que Protractor puisse naviguer le site
- sudo setfacl -R -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs app/sessions
- sudo setfacl -dR -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs app/sessions
override:
- php -d memory_limit=-1 bin/phpunit -c app
- protractor angutest
Thank you
I'm one of the CircleCI devs.
the most straightforward way is to run the PHP tests on one container and the JS tests on another, if they have approximately similar runtimes then you'll get the benefit without having to manually split test suites.
Something like the following would work in that case:
test:
override:
- case $CIRCLE_NODE_INDEX in 0) php -d memory_limit=-1 bin/phpunit -c app ;; 1) protractor angutest ;; esac:
parallel: true
I need my JavaEE-application to be deployed on Glassfish as a directory, not a packaged WAR file.
Is it possible to deploy a directory to Glassfish with the Maven Glassfish Plugin?
With the admin console, it's possible. But i want to be also able to do it on the command line.
The following configuration works for me (note that the artifact element points to a directory):
<plugin>
<groupId>org.glassfish.maven.plugin</groupId>
<artifactId>maven-glassfish-plugin</artifactId>
<version>2.2-SNAPSHOT</version>
<configuration>
<glassfishDirectory>${glassfish.home}</glassfishDirectory>
<user>${domain.username}</user>
<passwordFile>${glassfish.home}/domains/${project.artifactId}/master-password</passwordFile>
<autoCreate>true</autoCreate>
<debug>true</debug>
<echo>true</echo>
<skip>${test.int.skip}</skip>
<domain>
<name>${project.artifactId}</name>
<httpPort>8080</httpPort>
<adminPort>4848</adminPort>
</domain>
<components>
<component>
<name>${project.artifactId}</name>
<artifact>${project.build.directory}/${project.build.finalName}</artifact>
</component>
</components>
</configuration>
</plugin>
The resulting asadmin command is:
asadmin --host localhost --port 4848 --user admin --passwordfile /home/pascal/opt
/glassfishv3/glassfish/domains/maven-glassfish-testcase/master-password --interac
tive=false --echo=true --terse=true deploy --name maven-glassfish-testcase --forc
e=false --precompilejsp=false --verify=false --enabled=true --generatermistubs=fa
lse --availabilityenabled=false --keepreposdir=false --keepfailedstubs=false --lo
gReportedErrors=true --upload=false --help=false /home/pascal/Projects/stackoverf
low/maven-glassfish-testcase/target/maven-glassfish-testcase
I did not get it to work with the maven plugin, but it is possible to deploy to glassfish from the command line using the asadmin command from the glassfish/bin directory:
asadmin deploy --contextroot context_root path_to_ear_or_directory