To Add Junit tests in SonarQube - junit

I am not able to view Junit tests in Sonarqube coverage report. We are running the pipeline in bitbucket and project is based on SAP hybris.
bit-bucket-pipeline.yml
mage: atlassian/default-image:3
clone:
lfs: true
pipelines:
custom:
qg-sonarqube-main:
- step:
name: 'sq init'
image: atlassian/default-image:3
script:
- |
echo "start notification"
echo "install java"
apt update
apt install -y --no-install-recommends openjdk-11-jdk rsync tree
java --version
echo "sonarqube scan of current branch; build dir $BITBUCKET_CLONE_DIR"
# assembly first
echo "download scanner-cli"
wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli- 4.7.0.2747.zip -O $BITBUCKET_CLONE_DIR/sonarcli.zip
unzip -q $BITBUCKET_CLONE_DIR/sonarcli.zip -d $BITBUCKET_CLONE_DIR
ln -s $BITBUCKET_CLONE_DIR/sonar-scanner-4.7.0.2747/bin/sonar-scanner /bin/sonar-scanner
/bin/sonar-scanner -v
echo "hybris ootb assembly"
unzip -q ootb/CXCOM200500P_27-70004955.ZIP -d $BITBUCKET_CLONE_DIR
echo "unzip and copy modules"
unzip -q ootb/modules.zip -d $BITBUCKET_CLONE_DIR/hybris/bin/
echo "move sonar project configuration"
mv sonar-project.properties hybris/sonar-project.properties
echo "node version"
node -v
echo "move the customcode"
mv bin/custom hybris/bin/
echo "build the box"
cd hybris/bin/platform
. ./setantenv.sh
echo | ant clean
cd $BITBUCKET_CLONE_DIR
rsync -vau config/ hybris/config/
echo "check config dir"
cd hybris/bin/platform
ant customize
echo "copy valid props and localextensions taken from valid assembly"
ant build all
echo "scan"
cd $BITBUCKET_CLONE_DIR/hybris/
TODAY=$(date +'%d%m%Y')
echo "code version $BITBUCKET_BUILD_NUMBER.$TODAY"
/bin/sonar-scanner -Dsonar.login="$SONAR_LOGIN" -Dsonar.projectKey=alcon-"$BITBUCKET_BRANCH" -Dsonar.projectName=alcon-"$BITBUCKET_BRANCH" -Dsonar.projectVersion="$BITBUCKET_BUILD_NUMBER.$TODAY"
echo "waiting for CE"
# get ceTaskUrl var
source .scannerwork/report-task.txt
# up to 30 min
for _ in {0..60}; do
status=$(curl -s -H "Accept: application/json" -u "$SONAR_LOGIN:" $ceTaskUrl | jq -r .task.status)
case $status in
SUCCESS)
echo "notification about success"
echo "Task finished"
echo "Project dashboard: $dashboardUrl"
exit 0
;;
PENDING | IN_PROGRESS)
echo "Task still in progress"
sleep 30
;;
FAILED)
echo "notification about fail"
echo Got FAILED task status, exit
exit 1
;;
*)
echo "Unsupported task status: $status"
sleep 30
;;
esac
done
echo "Project dashboard: $dashboardUrl"
====================
Sonar-project.properties:
sonar.sources=bin/custom/
sonar.sourceEncoding=UTF-8
sonar.pdf.skip=true
sonar.language=java
sonar.java.source=1.8
sonar.java.binaries=bin/custom/
sonar.host.url=https://b2bint.sonarqube.alconcloud.com

Related

Is git ls-remote able to use GITHUB variables? Error: Process completed with exit code 2

Actions code:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout codes
uses: actions/checkout#v2
- name: Test git for actions
shell: bash
run: |
## use GitHub variables, such as: GITHUB_REF,GITHUB_HEAD_REF..
BRANCH=${GITHUB_REF##*/}
branch=$BRANCH
git ls-remote --heads --exit-code repo_url "$branch" >/dev/null
if [ "$?" == "1" ]
then
echo "Branch doesn't exist"
else
echo "Branch exist"
fi
It will occur the following error:
BRANCH=${GITHUB_REF##*/}
branch=${BRANCH}
echo $branch
git ls-remote --heads --exit-code repo_url "$branch" >/dev/null
if [ "$?" == "1" ]
then
echo "Branch doesn't exist"
else
echo "Branch exist"
fi
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
main
Error: Process completed with exit code 2.
When I replace ${GITHUB_REF} with main, it works fine.
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Test git for actions
shell: bash
run: |
## use GitHub variables, such as: GITHUB_REF,GITHUB_HEAD_REF..
BRANCH=${GITHUB_REF##*/}
branch=main
git ls-remote --heads --exit-code repo_url "$branch" >/dev/null
if [ "$?" == "1" ]
then
echo "Branch doesn't exist"
else
echo "Branch exist"
fi
Output:
BRANCH=${GITHUB_REF##*/}
branch=main
echo $branch
git ls-remote --heads --exit-code repo_url "$branch" >/dev/null
if [ "$?" == "1" ]
then
echo "Branch doesn't exist"
else
echo "Branch exist"
fi
main
Branch exist
Is the git ls-remote command not able to use variables?
I want to check whether a certain branch exists in the remote warehouse in GitHub Actions.
According to jobs.<job_id>.steps[*].shell, the default Bash invocation is:
bash --noprofile --norc -eo pipefail {0}
which makes it to fail fast as described under Exit codes and error action preference, for bash:
Fail-fast behavior using set -eo pipefail: This option is set when shell: bash is explicitly specified.
And, according to Bash manual, under The Set Builtin:
-e: Exit immediately if a pipeline (see Pipelines), which may consist of a single simple command (see Simple Commands), a list (see Lists of Commands), or a compound command (see Compound Commands) returns a non-zero status. The shell does not exit if the command that fails is part of the command list immediately following a while or until keyword, part of the test in an if statement, part of any command executed in a && or || list except the command following the final && or ||, any command in a pipeline but the last, or if the command’s return status is being inverted with !. If a compound command other than a subshell returns a non-zero status because a command failed while -e was being ignored, the shell does not exit. A trap on ERR, if set, is executed before the shell exits.
and,
-o pipefail: If set, the return value of a pipeline is the value of the last (rightmost) command to exit with a non-zero status, or zero if all commands in the pipeline exit successfully. This option is disabled by default.
In your case, the possible solution could be to directly handle the exit status of the command in an if:
if command; then
# succes
else
# failure
end
i.e.
if ! git ls-remote --heads --exit-code repo_url "$branch" >/dev/null
then
echo "Branch doesn't exist"
else
echo "Branch exist"
fi
or,
if git ls-remote --heads --exit-code repo_url "$branch" >/dev/null
then
echo "Branch exist"
else
echo "Branch doesn't exist"
fi

Update Zabbix with a script

I need to make a script that will update Zabbix on Ubuntu. It needs to update everything like the log files and so on. But I don't know how to make a script that will execute this. I've been trying to look up information on this subject but can't find anything.
Following is an old script that is used to install Zabbix-server automatically, but only for the first time, I think you must only edit thing which is required in the application
#!/bin/sh
#
# zabbix 2.0.2 install with postgresql and jabber support
#
#
# software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
#
# written by:
# Stefan Krueger
# tested on Debian Squeeze/Wheezy & Ubuntu 10.04 LTS/12.04 LTS (use sudo su -)
#
(
dbpw=$(dd if=/dev/urandom bs=1 count=6 2>/dev/null | openssl base64)
zbxver=zabbix-2.0.2
ipadd=$(env LC_ALL=C /sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp')
date
# update system
echo '###############'
echo 'update system'
echo '###############'
apt-get update
# install requirements
echo '###############'
echo 'install requirements'
echo '###############'
sleep 1
apt-get install -y postgresql build-essential fping apache2 php5 php5-pgsql php5-gd libsnmp-dev libcurl4-openssl-dev libapache2-mod-php5 libiksemel-dev libpq-dev libssh2-1-dev libopenipmi-dev
#DB setup
echo '###############'
echo 'database setup '
echo '###############'
sleep 1
adduser zabbix --no-create-home --system --group --disabled-password --shell /bin/false --quiet && echo 'User zabbix created' || echo 'User zabbix could not be created'
su postgres -c "echo \"create user zabbix with password '${dbpw}' createdb;\" | psql" && echo "database user zabbix created" || echo "database user zabbix could not be created"
su postgres -c "echo \"create database zabbix with owner=zabbix;\" | psql" && echo "database zabbix created" || echo "database zabbix could not be created"
sleep 2
# zabbix installation
echo '############################################################################'
echo ''
echo $zbxver installation
echo ''
echo '############################################################################'
cd /tmp/
mkdir -p /tmp/install
cd /tmp/install
wget http://prdownloads.sourceforge.net/zabbix/${zbxver}.tar.gz
tar -zxvf ${zbxver}.tar.gz
chmod -R 777 /tmp/install/*
su zabbix -s /bin/bash -c "psql -d zabbix -f /tmp/install/${zbxver}/postgresql/schema.sql" && echo "create schema success" || echo "create schema failed"
su zabbix -s /bin/bash -c "psql -d zabbix -f /tmp/install/${zbxver}/postgresql/images.sql" && echo "create schema success" || echo "create schema failed"
su zabbix -s /bin/bash -c "psql -d zabbix -f /tmp/install/${zbxver}/postgresql/data.sql" && echo "create schema success" || echo "create schema failed"
cd /tmp/install/${zbxver}
chmod +x /tmp/install/${zbxver}/configure
chmod +x ./configure
/tmp/install/${zbxver}/configure --enable-server --with-postgresql --with-net-snmp --with-libcurl --with-openipmi --with-jabber --with-ssh2 --enable-agent --prefix=/usr --mandir=\${prefix}/share/man --infodir=\${prefix}/share/info --sysconfdir=/etc/zabbix || exit
make install
#install frontend
echo '############################################################################'
echo ''
echo '$zbxver installation'
echo ' FRONTEND installation'
echo ''
echo '############################################################################'
sleep 1
sed -i.backup -e "s/post_max_size = 8M/post_max_size = 32M/g" -e "s/max_execution_time = 30/max_execution_time = 600/g" -e "s/max_input_time = 60/max_input_time = 600/g" -e '/date.timezon/a\date.timezone = "Europe/Berlin"' /etc/php5/apache2/php.ini
cd /tmp/install/${zbxver}/frontends/php
mkdir -p /var/www/zabbix
cp -a . /var/www/zabbix
chown www-data:www-data -R /var/www/zabbix
cat <<EOF > /etc/apache2/sites-available/zabbix
<VirtualHost /zabbix>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/zabbix
<Directory />
Options FollowSymLinks Indexes MultiViews
AllowOverride None
</Directory>
</VirtualHost>
EOF
echo '############################################################################'
echo ''
echo '$zbxver installation'
echo ' services installation agent & server'
echo ''
echo '############################################################################'
sleep 1
mkdir -p /var/log/zabbix && chown zabbix /var/log/zabbix && chmod 760 /var/log/zabbix
mkdir -p /var/run/zabbix && chown zabbix /var/run/zabbix && chmod 760 /var/run/zabbix
#cp /tmp/install/${zbxver}/misc/conf/zabbix_server.conf /etc/zabbix
#cp /tmp/install/${zbxver}/misc/conf/zabbix_agentd.conf /etc/zabbix
sed -i.backup -e "s|DBUser=root|DBUser=zabbix|g" -e "s|# DBPassword=|DBPassword=${dbpw}|g" -e "s|/tmp/zabbix_server.log|/var/log/zabbix/zabbix_server.log|g" -e "s|# PidFile=/tmp/zabbix_server.pid|PidFile=/var/run/zabbix/zabbix_server.pid|g" -e "s|# HousekeepingFrequency=1|HousekeepingFrequency=24|" /etc/zabbix/zabbix_server.conf
sed -i.backup -e "s|/tmp/zabbix_agentd.log|/var/log/zabbix/zabbix_agentd.log|g" -e "s|# PidFile=/tmp/zabbix_agentd.pid|PidFile=/var/run/zabbix/zabbix_agentd.pid|g" /etc/zabbix/zabbix_agentd.conf
chown -R zabbix:zabbix /etc/zabbix
cp /tmp/install/${zbxver}/misc/init.d/debian/zabbix* /etc/init.d/
sed -i.backup -e "s|/usr/local/sbin/|/usr/sbin/|" -e "s|PID=/tmp/|PID=/var/run/zabbix/|" /etc/init.d/zabbix-server
sed -i.backup -e "s|/usr/local/sbin/|/usr/sbin/|" -e "s|PID=/tmp/|PID=/var/run/zabbix/|" /etc/init.d/zabbix-agent
chmod 775 /etc/init.d/zabbix-server
chmod 775 /etc/init.d/zabbix-agent
update-rc.d zabbix-server defaults 90
update-rc.d zabbix-agent defaults 99
/etc/init.d/zabbix-agent start
/etc/init.d/zabbix-server start
/etc/init.d/apache2 restart
echo ""
echo ""
echo ""
if [ -e /var/run/zabbix/zabbix_server.pid ]; then echo " zabbix-server started succesfully"
else echo " !! zabbix-server dont start"
fi
if [ -e /var/run/zabbix/zabbix_agentd.pid ]; then echo " zabbix-agentd started succsfully"
else echo " !! zabbix-agentd dont start"
fi
echo " look at the zabbix_install.log"
echo ""
echo " please configure you postgresql.conf"
echo " the database password for zabbix is: ${dbpw}"
echo ""
echo " now you can configure the zabbix-frontend http://${ipadd}/zabbix"
) | tee zabbix_install.log

Issues installing IDAS on CentOS 7 VM through provided RPMs

I've been trying to install IDAS GE in a CentOS 7 VM on my machine through the UL2.0 RPMs(download link!) available in its catalogue page.
I followed the instructions on github, but I get stuck in starting the IoT as per section 3 of the Deployment section of the instructions. If I execute the init_iotagent.sh, where I inserted the local IP of the VM, I get the error:
log4cplus:ERROR No appenders could be found for logger (main).
log4cplus:ERROR Please initialize the log4cplus system properly.
HTTPFilter DESTRUCTOR 0
HTTPFilter DESTRUCTOR 0
Also, in the instructions for Starting IoTAgent as a Service, it's said that:
After installing iot-agent-base RPM an init.d script can be found in
this folder /usr/local/iot/init.d .
But this file is not there, leading me to believe that the IoTAgent wasn't installed properly from the RPMs provided.
Also, I can't find log files regarding IoTAgent, only the MongoDB has its log file at /usr/local/iot/mongodb-linux-x86_64-2.6.9/log/mongoc.log.
If anyone could help, it would be apreciated. Also, if more info is needed, please let me know.
Thank you
I recommend you to get the GitHub repository and build the RPMs from the source and then install it in your CentOS. Like is explained in the documentation:
NOTE: I changed the BUILD_TYPE to Release, so I created the Release dir.
GIT_VERSION and GIT_COMMIT are not the latest ones.
git clone https://github.com/telefonicaid/fiware-IoTAgent-Cplusplus.git
cd fiware....
mkdir -p build/Release
cd build/Release
cmake -DGIT_VERSION=20527 -DGIT_COMMIT=217023407f25ed258043cfc00a46b6c05fb0b52c -DMQTT=ON -DCMAKE_BUILD_TYPE=Release ../../
make install
make package
The packages will be in pack/Linux/RPM/
rpm -i iot-agent-base-xxxxxxx (xxxxxxx will be the numbers of the build)
rpm -i iot-agent-ul-xxxxxx (xxxxxxx will be the numbers of the build)
Once installed with RPMs the init.d file is in: /usr/local/iot/init.d/iotagent
This is the content of the file:
#!/bin/bash
# Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U
#
# This file is part of fiware-IoTagent-Cplusplus (FI-WARE project).
#
# iotagent Start/Stop iotagent
#
# chkconfig: 2345 99 60
# description: iotagent
. /etc/rc.d/init.d/functions
PARAM=$1
INSTANCE=$2
USERNAME=iotagent
EXECUTABLE=/usr/local/iot/bin/iotagent
CONFIG_PATH=/usr/local/iot/config
iotagent_start()
{
local result=0
local instance=${1}
if [[ ! -x ${EXECUTABLE} ]]; then
printf "%s\n" "Fail - missing ${EXECUTABLE} executable"
exit 1
fi
if [[ -z ${instance} ]]; then
list_instances="${CONFIG_PATH}/iotagent_*.conf"
else
list_instances="${CONFIG_PATH}/iotagent_${instance}.conf"
fi
for instance_config in ${list_instances}
do
local NAME
NAME=${instance_config%.conf}
NAME=${NAME#*iotagent_}
source ${instance_config}
local IOTAGENT_PID_FILE="/var/run/iot/iotagent_${NAME}.pid"
printf "Starting iotagent ${NAME}..."
status -p ${IOTAGENT_PID_FILE} ${EXECUTABLE} &> /dev/null
if [[ ${?} -eq 0 ]]; then
printf "%s\n" " Already running, skipping $(success)"
continue
fi
# Load the environment
set -a
source ${instance_config}
# Mandatory parameters
IOTAGENT_OPTS=" ${IS_MANAGER} \
-n ${IOTAGENT_SERVER_NAME} \
-v ${IOTAGENT_LOG_LEVEL} \
-i ${IOTAGENT_SERVER_ADDRESS} \
-p ${IOTAGENT_SERVER_PORT} \
-d ${IOTAGENT_LIBRARY_DIR} \
-c ${IOTAGENT_CONFIG_FILE}"
su ${USERNAME} -c "LD_LIBRARY_PATH=\"${IOTAGENT_LIBRARY_DIR}\" \
${EXECUTABLE} ${IOTAGENT_OPTS} & echo \$! > ${IOTAGENT_PID_FILE}" &> /dev/null
sleep 2 # wait some time to leave iotagent start
local PID=$(cat ${IOTAGENT_PID_FILE})
local var_pid=$(ps -ef | grep ${PID} | grep -v grep)
if [[ -z "${var_pid}" ]]; then
printf "%s" "pidfile not found"
printf "%s\n" "$(failure)"
exit 1
else
printf "%s\n" "$(success)"
fi
done
return ${result}
}
iotagent_stop()
{
local result=0
local iotagent_instance=${1}
if [[ -z ${iotagent_instance} ]]; then
list_run_instances="/var/run/iot/iotagent_*.pid"
else
list_run_instances="/var/run/iot/iotagent_${iotagent_instance}.pid"
fi
if [[ $(ls -l ${list_run_instances} 2> /dev/null | wc -l) -eq 0 ]]; then
printf "%s\n" "There aren't any instance of IoTAgent ${iotagent_instance} running $(success)"
return 0
fi
for run_instance in ${list_run_instances}
do
local NAME
NAME=${run_instance%.pid}
NAME=${NAME#*iotagent_}
printf "%s" "Stopping IoTAgent ${NAME}..."
local RUN_PID=$(cat ${run_instance})
kill ${RUN_PID} &> /dev/null
local KILLED_PID=$(ps -ef | grep ${RUN_PID} | grep -v grep | awk '{print $2}')
if [[ -z ${KILLED_PID} ]]; then
printf "%s\n" "$(success)"
else
printf "%s\n" "$(failure)"
result=$((${result}+1))
fi
rm -f ${run_instance} &> /dev/null
done
return ${result}
}
iotagent_status()
{
local result=0
local iotagent_instance=${1}
if [[ -z ${iotagent_instance} ]]; then
list_run_instances="/var/run/iot/iotagent_*.pid"
else
list_run_instances="/var/run/iot/iotagent_${iotagent_instance}.pid"
fi
if [[ $(ls -l ${list_run_instances} 2> /dev/null | wc -l) -eq 0 ]]; then
printf "%s\n" "There aren't any instance of IoTAgent ${iotagent_instance} running."
return 1
fi
for run_instance in ${list_run_instances}
do
local NAME
NAME=${run_instance%.pid}
NAME=${NAME#*iotagent_}
printf "%s\n" "IoTAgent ${NAME} status..."
status -p ${run_instance} ${NODE_EXEC}
result=$((${result}+${?}))
done
return ${result}
}
case ${PARAM} in
'start')
iotagent_start ${INSTANCE}
;;
'stop')
iotagent_stop ${INSTANCE}
;;
'restart')
iotagent_stop ${INSTANCE}
iotagent_start ${INSTANCE}
;;
'status')
iotagent_status ${INSTANCE}
;;
esac
And the logs file are in /tmp/ :
IoTAgent-IoTPlatform.log
IoTAgent.log
IoTAgent-Manager.log
Hope this helps you.

Issue with Facelets page regarding embeded scripts code in a 'code' element

Very confusing question I know, and it's a bit of a gobstopper for me!
I am trying to display bash script code in a Facelets page so that user can copy the scripts code from browser. This code is placed in a code element as posted below. But requesting the page gives me error(s) related to what I think is the cause (in bold). I have tried replacing the {, }, & - characters with the html replacements and I still get errors. Perhaps this is not allowed?
#!/bin/bash
#Author: Yucca Nel http://thejarbar.org
#Will restart system
#Modify these variables as needed...
tempWork=/tmp/work
defaultStartScript=/etc/init.d/rc.local
defaultMaven=3.0.4
locBin=/usr/local/bin
mavenUsrLib=/usr/lib/maven
sudo mkdir -p $mavenUsrLib
mkdir -p $HOME/.m2
read -p "Please [Enter] full path name of your local startup script ($defaultStartScript is the default). Please
make sure on this before providing a value by consulting documentation for your system:" locStartScript
locStartScript=${locStartScript:-$defaultStartScript}
read -p "Please [Enter] Maven Version ($defaultMaven is default):" mavenVersion
mavenVersion=${mavenVersion:-$defaultMaven}
if [ ! -f $locStartScript ]
then
echo "The file you provided could not be found. Remember to include the full path and try again. Exiting in 7 secs..."
sleep 7
exit 1
fi
mkdir -p /$tempWork
cd /$tempWork
wget http://mirrors.powertech.no/www.apache.org/dist//maven/binaries/apache-maven-$mavenVersion-bin.tar.gz
tar -zxvf ./
#Move it to a more logical location
sudo mv -f ./apache-maven-$mavenVersion $mavenUsrLib/
#If you have Maven on Windows and use VirtualBox, you can set up the maven to be a virtualbox shared folder.
#The name must match the name used below (ignore if irrelevant to you).
if [ -f /sbin/mount.vboxsf ]
then
sudo /sbin/umount $HOME/.m2
sudo /sbin/umount $mavenUsrLib
sudo /sbin/mount.vboxsf .m2 $HOME/.m2
sudo /sbin/mount.vboxsf maven $mavenUsrLib
fi
if mountpoint -q $HOME/.m2 && mountpoint -q $mavenUsrLib
then
#Add it to the start script to automate process...
if ! grep "sudo /sbin/mount.vboxsf .m2 $HOME/.m2" $locStartScript
then
echo "sudo /sbin/mount.vboxsf .m2 $HOME/.m2" | sudo tee -a $locStartScript
fi
if ! grep "sudo /sbin/mount.vboxsf maven $mavenUsrLib" $locStartScript
then
echo "sudo /sbin/mount.vboxsf maven $mavenUsrLib" | sudo tee -a $locStartScript
fi
echo "exit 0" | sudo tee -a $locStartScript
sudo chmod +x $locStartScript
#Create a mount and unmount script file...
rm -rf $tempWork/
echo '#!/bin/bash' > $tempWork/maven-mount.sh
echo "sudo /sbin/mount.vboxsf .m2 $HOME/.m2" >> $tempWork/maven-mount.sh
echo "sudo /sbin/mount.vboxsf maven $mavenUsrLib" >> $tempWork/maven-mount.sh
echo "echo 'mounted maven'" >> $tempWork/maven-mount.sh
echo "exit 0" >> $tempWork/maven-mount.sh
echo '#!/bin/bash' > $tempWork/maven-umount.sh
echo "sudo umount $HOME/.m2" >> $tempWork/netbeans-umount.sh
echo "sudo umount $mavenUsrLib" >> $tempWork/netbeans-umount.sh
echo "echo 'unmounted maven'" >> $tempWork/maven-mount.sh
echo 'exit 0' >> $tempWork/maven-umount.sh
#Script for mounting ALL VirtualBox shared solders....
#If there isn't one create one...
if [ ! -f $locBin/mount-all-from-host.sh ]
then
echo '#!/bin/bash' > $tempWork/mount-all-from-host.sh
echo "sudo /sbin/mount.vboxsf .m2 $HOME/.m2" | sudo tee -a $tempWork/mount-all-from-host.sh
echo "sudo /sbin/mount.vboxsf maven $mavenUsrLib" | sudo tee -a $tempWork/mount-all-from-host.sh
echo "exit 0" | sudo tee -a $tempWork/mount-all-from-host.sh
#Otherwise if there is one, but no mount, add one...
elif ! grep "sudo /sbin/mount.vboxsf .m2 $HOME/.m2" $locBin/mount-all-from-host.sh
then
sudo sed -ie '$d' $locBin/mount-all-from-host.sh
echo "sudo /sbin/mount.vboxsf .m2 $HOME/.m2" | sudo tee -a $locBin/mount-all-from-host.sh
echo "exit 0" | sudo tee -a $locBin/mount-all-from-host.sh
elif ! grep "sudo /sbin/mount.vboxsf maven $mavenUsrLib" $locBin/mount-all-from-host.sh
then
sudo sed -ie '$d' $locBin/mount-all-from-host.sh
echo "sudo /sbin/mount.vboxsf maven $mavenUsrLib" | sudo tee -a $locBin/mount-all-from-host.sh
echo "exit 0" | sudo tee -a $locBin/mount-all-from-host.sh
fi
#Script for unmounting ALL VirtualBox shared folders...
#If there isn't one create one...
if [ ! -f $locBin/umount-all-from-host.sh ]
then
echo '#!/bin/bash' > $tempWork/umount-all-from-host.sh
echo "sudo umount -a -t vboxsf" | sudo tee -a $tempWork/umount-all-from-host.sh
echo "echo 'unmounted all VirtualBox shared folders'" | sudo tee -a $tempWork/umount-all-from-host.sh
echo "exit 0" | sudo tee -a $tempWork/umount-all-from-host.sh
fi
sudo chmod +x $tempWork/
sudo mv -f $tempWork/.sh $locBin/
rm -rf $tempWork
fi
sudo ln -f -s $mavenUsrLib/apache-maven-$mavenVersion/bin/* /usr/bin/
sudo rm -rf $tempWork
sudo /sbin/reboot
exit 0
Solved: mavenVersion=$<h:outputText value="{mavenVersion:-$defaultMaven}"/><br/>

creating ipa file using command line with code signing

I am trying to create an ipa file using xcode command line including signing.
i tried searching for it, i got the commands to create ipa with out code signing.
i need the commands mainly to integrate with hudson CI.
Please suggest.
-Prahasa
This is the script which I use to integrate with Hudson and my iPhone Apps.
#!/bin/sh
CONFIGURATION="AdHoc" # or Release or Debug
# location of files included in dist (.mobileprovision, iTunesArtwork, README)
DISTDIR="_distfiles"
. build.config
MARKETING_VERSION=`agvtool what-marketing-version -terse1`
build_xcode ()
{
xcodebuild -configuration "$CONFIGURATION" -sdk $SDK
}
# CONFIGURATION for xcode build can be overridden from commandline
NEWCONFIG="$1"
if ! test "$NEWCONFIG"x = x; then
echo "=== using configuration from command line $NEWCONFIG"
CONFIGURATION="$NEWCONFIG"
fi
# XCODE check build available for specified configuration
CHECKCONFIGURATION=`xcodebuild -list | egrep "$CONFIGURATION($|\ )"`
if test "$CHECKCONFIGURATION"x = x; then
echo "ERROR: xcodebuild could not find valid build configuration $CONFIGURATION"
echo
xcodebuild -list
echo
exit
fi
VERSION="$MARKETING_VERSION ($BUILD_NUMBER)"
#######
echo "=== Building distribution package for $RELEASE - $VERSION"
echo "=== setting build number to $BUILD_NUMBER"
agvtool new-version -all "${BUILD_NUMBER}"
# XCODE make sure buildpath exists for configuration, build if missing
BUILDPATH="build/$CONFIGURATION-iphoneos"
build_xcode
if [ $? != 0 ]; then
echo "ERROR: xcodebuild not successful"
exit 1
fi
if test ! -d "$BUILDPATH"; then
echo "ERROR: xcodebuild could not build configuration $CONGIRUATION ($BUILDPATH)"
exit
fi
echo "=== Successfully built configuration $CONFIGURATION ($BUILDPATH)"
# HACK : accomodate configurations with spaces, chdir to determine app name
cd "$BUILDPATH"
# derive name of .app dir (application)
APPDIR=`ls -d *.app`
cd ../..
APPPATH="$BUILDPATH/$APPDIR"
DSYMPATH="$BUILDPATH/$APPDIR.dSYM"
if test "$APPDIR"x = x; then
APPPATH="$BUILDPATH/.app"
fi
# XCODE make sure app dir exists in buildpath, build if missing
if test ! -d "$APPPATH"; then
echo "missing $APPPATH build in $BUILDPATH, trying to build"
build_xcode
# HACK : accomodate configurations with spaces, chdir to determine app name
cd "$BUILDPATH"
# derive name of .app dir (application)
APPDIR=`ls -d *.app`
cd ../..
# check again for APPDIR/APPPATH
APPPATH="$BUILDPATH/$APPDIR"
if test "$APPDIR"x = x; then
APPPATH="$BUILDPATH/.app"
fi
if test ! -d "$APPPATH"; then
echo "ERROR: xcodebuild could not build $APPPATH configuration $CONGIRUATION ($BUILDPATH)"
exit
fi
echo "=== Successfully built $APPDIR configuration $CONFIGURATION ($BUILDPATH)"
fi
# Create directory for release package
echo " - Creating release dir"
RELEASEDIR="$RELEASEBASE/$RELEASE-$CONFIGURATION-$MARKETING_VERSION-$BUILD_NUMBER"
mkdir -p "$RELEASEDIR"
echo "RELEASEDIR = $RELEASEDIR"
echo "BUILDPATH = $BUILDPATH"
echo "APPPATH = $APPPATH"
echo "DSYMPATH = $APPPATH"
# Copy other files
cp $DISTDIR/* "$RELEASEDIR"
# .IPA file: iphone app archive file, installable by itunes
IPA=`echo $APPDIR | sed "s/\.app/\.ipa/"`
echo " - Creating $IPA payload"
mkdir -p "$RELEASEDIR/Payload/"
echo " - Copying $APPPATH to $RELEASEDIR/Payload/"
# Copy built .app to payload/ itunes-specific install dir
cp -Rp "$APPPATH" "$RELEASEDIR/Payload/"
# Build .IPA file
# this is just a zipfile with a payload/ dir with the .app, and artwork
cd "$RELEASEDIR"
# include 512x512 png of artwork, if foudn
if test -f "iTunesArtwork"; then
zip -y -r "$IPA" iTunesArtwork Payload/
rm -rf Payload iTunesArtwork
else
zip -y -r "$IPA" Payload/
rm -rf Payload
fi
cd ..
pwd
# Create .zip packaged Distribution
ZIPFILE="$RELEASE-$CONFIGURATION-$MARKETING_VERSION-$BUILD_NUMBER.zip"
DSYMZIPFILE="$RELEASE-$CONFIGURATION-$MARKETING_VERSION-$BUILD_NUMBER-dSYM.zip"
echo " - zipfile is $ZIPFILE"
echo " - Compressing release $ZIPFILE"
zip -y -r "$ZIPFILE" "$RELEASE-$CONFIGURATION-$MARKETING_VERSION-$BUILD_NUMBER"
cp -pR "../$DSYMPATH" "$RELEASE-$CONFIGURATION-$MARKETING_VERSION-$BUILD_NUMBER"
echo " - creating zip of dSYM file"
zip -y -r "$DSYMZIPFILE" "$RELEASE-$CONFIGURATION-$MARKETING_VERSION-$BUILD_NUMBER/$APPDIR.dSYM"
cd ..
echo "=== Build complete for $RELEASEBASE/$ZIPFILE"
Then, my hudson configuration looks like this:
./build.sh AdHoc
./build.sh Release
Finally, my files to archive looks like this:
_release/MobilePracticePro-*-${BUILD_NUMBER}*.zip
Hope this is helpful to you! Using Hudson is really great. Also, realize your signing key needs to be installed on the same box as hudson runs and running as same user. At least that is how it is for me.
I have been facing the same issue and resolved by using the steps give in the details of the link Xcode "Build and Archive" from command line