Follow this link for install jenkins in ubuntu.
https://www.digitalocean.com/community/tutorials/how-to-install-jenkins-on-ubuntu-16-04
Step 1 : Click on new item then select Free style project.
Step 2 : Go to customize project. Tick on gitHub project under general tab and add git project url.
Step 3 : Under source code management tick on git. Then add git url and credentials.
Step 4: If you want to auto build when push code to git, tick on GitHub hook trigger for GITScm polling .
Step 5: Select execute shell under Build section.
Here is the example of execute shell commands
ROOT="$PWD"
APIPROJECT=api
WEBPROJECT=web2
SEARCHPROJECT=search
cd "${ROOT}/${APIPROJECT}"
composer install
cat << EOF > .env
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:Snp4kGO0Nq4wbcK4B9tzUgcewMebwJ9he+MLs5a4NtU=
APP_DEBUG=false
APP_LOG_LEVEL=debug
APP_URL=
DB_CONNECTION=mysql
DB_HOST=
DB_PORT=3306
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sqs
SQS_KEY=
SQS_SECRET=
SQS_PREFIX=
SQS_QUEUE=
SQS_REGION=us-west-2
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=email-smtp.us-west-2.amazonaws.com
MAIL_PORT=587
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
# S3 config
AWS_ACCESS_KEY_ID =
AWS_SECRET_ACCESS_KEY =
AWS_DEFAULT_REGION =
AWS_BUCKET =
REQUEST_RATE=100000
MAIL_CHIMP_REGION=us17
MAIL_CHIMP_LIST_ID=
MAIL_CHIMP_USER_NAME=
MAIL_CHIMP_API_KEY=
SUPPORT_EMAIL=
ADMIN_EMAIL=
FROM_EMAIL=
FRONT_END_URL=
BACK_OFFICE_URL=
ELASTIC_SEARCH_DOMAIN=
ELASTIC_SEARCH_INDEX=
CA_USERID=
CA_PASSWORD=
CA_BASEURL=
SERVER_ENVIRONMENT=
EOF
php artisan key:generate
php artisan migrate
php artisan passport:keys
php vendor/bin/phpunit
cd ${ROOT}/${WEBPROJECT}
yarn
cat << EOF > .env
REACT_APP_APP_HOST_ROOT=
REACT_APP_APP_HOST=
REACT_APP_AUTH_CLIENT_ID=
REACT_APP_AUTH_CLIENT_SECRET=
REACT_APP_AUTH_GRANT_TYPE=
REACT_APP_SEARCH_API=
EOF
yarn build
yarn build:admin
cd "${ROOT}/${SEARCHPROJECT}"
yarn --production
cat << EOF > .env
ELASTIC_SEARCH_URLS="http://example.com:9200,http://example.org:9200"
PHP_APP_URLS="http://localhost:80"
EOF
# TODO: sync search api, make ecosystem.json, and pm2 startOrReload
sh /data/scripts/sync -env dev -type web -appdir ${WEBPROJECT}/build
sh /data/scripts/sync -env dev -type app -appdir api
sh /data/scripts/sync -env dev -type office -appdir ${WEBPROJECT}/build-admin
another script text in local,
sh /home/prabhath/Desktop/ichem/sync
Step 6: Create script for copy build to www folder.
/usr/bin/rsync -v -a --no-owner --no-group --delete-during $BUILDDIR root@${HOST}:/var/www/html/
/usr/bin/ssh root@${HOST} /bin/chown -R apache:apache /var/www/html
sync script example:
echo "This is a shell script"
cp -r /var/lib/jenkins/workspace/test-project2/api/* /home/prabhath/Desktop/ichem/test_sync
echo "I am done running ls"
SOMEVAR='text stuff'
echo "$SOMEVAR"
Thursday, July 5, 2018
Set up jenkins
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment