...
Bloc de code |
---|
#!/bin/bash if [ ! -e node_modules ] then mkdir node_modules fi case `uname -s` in MINGW* | Darwin*) USER_UID=1000 GROUP_UID=1000 ;; *) if [ -z ${USER_UID:+x} ] then USER_UID=`id -u` GROUP_GID=`id -g` fi esac # Options NO_DOCKER="" SPRINGBOARD="recette" for i in "$@" do case $i in -s=*|--springboard=*) SPRINGBOARD="${i#*=}" shift ;; --no-docker*) NO_DOCKER="true" shift ;; *) ;; esac done clean () { if [ "$NO_DOCKER" = "true" ] ; then rm -rf node_modules rm -f yarn.lock gradle clean else docker-compose run --rm -u "$USER_UID:$GROUP_GID" gradle gradle clean fi } buildNode () { #jenkins echo "[buildNode] Get branch name from jenkins env..." BRANCH_NAME=`echo $GIT_BRANCH | sed -e "s|origin/||g"` if [ "$BRANCH_NAME" = "" ]; then echo "[buildNode] Get branch name from git..." BRANCH_NAME=`git branch | sed -n -e "s/^\* \(.*\)/\1/p"` fi if [ "$BRANCH_NAME" = "" ]; then echo "[buildNode] Branch name should not be empty!" exit -1 fi if [ "$BRANCH_NAME" = 'master' ]; then echo "[buildNode] Use entcore version from package.json ($BRANCH_NAME)" case `uname -s` in MINGW*) if [ "$NO_DOCKER" = "true" ] ; then yarn install --no-bin-links && npmyarn updateupgrade entcore && node_modules/gulp/bin/gulp.js build else docker-compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "yarn install --no-bin-links --legacy-peer-deps --force && npmyarn updateupgrade entcore && node_modules/gulp/bin/gulp.js build" fi ;; *) if [ "$NO_DOCKER" = "true" ] ; then yarn install && npmyarn updateupgrade entcore && node_modules/gulp/bin/gulp.js build else docker-compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "yarn install --legacy-peer-deps --force && npmyarn updateupgrade entcore && node_modules/gulp/bin/gulp.js build" fi esac else echo "[buildNode] Use entcore tag $BRANCH_NAME" case `uname -s` in MINGW*) if [ "$NO_DOCKER" = "true" ] ; then yarn install && npmyarn updateupgrade entcore && node_modules/gulp/bin/gulp.js build else docker-compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "yarn install --no-bin-links --legacy-peer-deps --force && npm rm --no-save entcore && yarn install --no-save entcore@dev && node_modules/gulp/bin/gulp.js build" fi ;; *) if [ "$NO_DOCKER" = "true" ] ; then yarn install --no-bin-links && npmyarn updateupgrade entcore && node_modules/gulp/bin/gulp.js build else docker-compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "yarn install --legacy-peer-deps --force && npm rm --no-save entcore && yarn install --no-save entcore@dev && node_modules/gulp/bin/gulp.js build" fi esac fi } buildGradle () { if [ "$NO_DOCKER" = "true" ] ; then gradle shadowJar install publishToMavenLocal else docker-compose run --rm -u "$USER_UID:$GROUP_GID" gradle gradle shadowJar install publishToMavenLocal fi } publish () { if [ -e "?/.gradle" ] && [ ! -e "?/.gradle/gradle.properties" ] then echo "odeUsername=$NEXUS_ODE_USERNAME" > "?/.gradle/gradle.properties" echo "odePassword=$NEXUS_ODE_PASSWORD" >> "?/.gradle/gradle.properties" echo "sonatypeUsername=$NEXUS_SONATYPE_USERNAME" >> "?/.gradle/gradle.properties" echo "sonatypePassword=$NEXUS_SONATYPE_PASSWORD" >> "?/.gradle/gradle.properties" fi if [ "$NO_DOCKER" = "true" ] ; then gradle publish else docker-compose run --rm -u "$USER_UID:$GROUP_GID" gradle gradle publish fi } watch () { if [ "$NO_DOCKER" = "true" ] ; then node_modules/gulp/bin/gulp.js watch --springboard=../recette else docker-compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "node_modules/gulp/bin/gulp.js watch --springboard=/home/node/$SPRINGBOARD" fi } for param in "$@" do case $param in clean) clean ;; buildNode) buildNode ;; buildGradle) buildGradle ;; install) buildNode && buildGradle ;; watch) watch ;; publish) publish ;; *) echo "Invalid argument : $param" esac if [ ! $? -eq 0 ]; then exit 1 fi done |
...