Git Version Control: Push Deployment
I have a repository set up in cPanel's Git Version Control with Pull deployment. Now, due to the project guidelines having changed, I would need to change this to push deployment.
I tried simply adding a cpanel.yml file to my repository as well as creating a brand new one (following the documentation at
-
Hello, It's a bit hard to answer this without knowing more about your setup. Would you be willing to submit a support ticket so that we can investigate this more directly? We look forward to hearing back from you. 0 -
Hi HB, Thanks for the reponse. Actually, in the time it took to get a response, I managed to debug the problem myself. I am however still experiencing problems with the .cpanel.yml file, the documentation about this being quite sparse. I have it set up correctly to copy the repository content into 2 subfolders. I next need it to run some npm commands to auto-deploy my app. Here is the file: --- deployment: tasks: - export DEPLOYPATHFRONT=/home/[user]/public_html/new_site/frontend - /bin/cp -R frontend/* $DEPLOYPATHFRONT - export DEPLOYPATHBACK=/home/[user]/public_html/new_site/backend - /bin/cp -R backend/* $DEPLOYPATHBACK - npm run build --prefix /home/[user]/public_html/new_site/backend - npm run start --prefix /home/[user]/public_html/new_site/backend - npm run build --prefix /home/[user]/public_html/new_site/frontend - npm run start --prefix /home/[user]/public_html/new_site/frontend
The first 4 lines of this are working fine. The lines relating to npm, which do work in a shell through ssh, don't seem to be running at all (I can't either seem to find errors being logged anywhere). Would you have some insight into this? Thanks!0 -
Hello, My suspicion is that the "npm" binary is likely not found in the $PATH environment variable of the running deployment script. I assume you are using the ea-nodejs10 packages -- if so, can you add export PATH=/opt/cpanel/ea-nodejs10/bin/:$PATH
near the start of your tasks to see if that resolves the issue? It would need to go above the npm lines. We look forward to hearing back from you.0 -
Hi HB, Thank you for the response. I'm not quite sure how to apply this to my code though. I've updated the file to look like this: --- deployment: tasks: - export DEPLOYPATHFRONT=/home/[user]/public_html/new_site/frontend - /bin/cp -R frontend/* $DEPLOYPATHFRONT - export DEPLOYPATHBACK=/home/[user]/public_html/new_site/backend - /bin/cp -R backend/* $DEPLOYPATHBACK - export PATH=/home/[user]/bin/:$PATH - npm run build --prefix /home/[user]/public_html/new_site/backend - npm run start --prefix /home/[user]/public_html/new_site/backend
I'm not using ea-nodejs10, I've installed it manually on the server in the bin directory. Do my 'npm run...' lines need to reference $PATH at all? And why does the PATH variable need to reference itself? Thanks!0 -
I'm not using ea-nodejs10, I've installed it manually on the server in the bin directory.
If you installed it system-wide to a normal bin directory (/usr/local/sbin
,/usr/local/bin
,/usr/sbin
, or/usr/bin
), then you likely don't need to worry about it. But I'll answer your other two questions.Do my 'npm run...' lines need to reference $PATH at all?
No.And why does the PATH variable need to reference itself?
It's to add to the existing variable without wiping out the current contents. But in any case, lets take a step back. It will be a lot easier if you confirm what errors you are getting.The lines relating to npm, which do work in a shell through ssh, don't seem to be running at all (I can't either seem to find errors being logged anywhere).
Any errors will be logged to/home/${USERNAME}/.cpanel/logs/vc_${EPOCH_TIMESTAMP}.${PID}_git_deploy.log
You should get the log location when you push your commit. For example:user:~/gittest/project $ git push gittest@${IP}:./project Enter passphrase for key '/Users/user/.ssh/id_rsa': Enumerating objects: 4, done. Counting objects: 100% (4/4), done. Delta compression using up to 4 threads Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 268 bytes | 268.00 KiB/s, done. Total 3 (delta 1), reused 0 (delta 0) remote: Recieved update on checked-out branch, queueing deployment. remote: --- remote: apiversion: 3 remote: func: create remote: module: VersionControlDeployment remote: result: remote: data: remote: deploy_id: 2 remote: log_path: /home/gittest/.cpanel/logs/vc_1577411725.94144_git_deploy.log remote: repository_root: /home/gittest/project remote: sse_url: /sse/UserTasks/00000000_5e05648de646f9/vc_1577411725.94144_git_deploy.log remote: task_id: 00000000/5e05648de646f9 remote: timestamps: remote: queued: '1577411726.01702' remote: errors: ~ remote: messages: ~ remote: metadata: {} remote: remote: status: 1 remote: warnings: ~ To ${IP}:./project 49d6da4..164896f master -> master
On your server, is there anything in /home/USERNAME/.cpanel/logs/ that provides information on what the problem is?0 -
Hi HB, Sorry for the delay, the holidays quickly became a busy time for me. I've located what seems to be the latest log file on this process, here is what it contains: 1576778783.182291412 $ export DEPLOYPATHFRONT=/home/[user]/public_html/new_site/frontend Task completed with exit code 0. 1576778783.188624087 $ /bin/cp -R frontend/* $DEPLOYPATHFRONT /bin/cp: 'frontend/components' and '/home/[user]/public_html/new_site/frontend/components' are the same file /bin/cp: 'frontend/next.config.js' and '/home/[user]/public_html/new_site/frontend/next.config.js' are the same file /bin/cp: 'frontend/node_modules' and '/home/[user]/public_html/new_site/frontend/node_modules' are the same file /bin/cp: 'frontend/out' and '/home/[user]/public_html/new_site/frontend/out' are the same file /bin/cp: 'frontend/package-lock.json' and '/home/[user]/public_html/new_site/frontend/package-lock.json' are the same file /bin/cp: 'frontend/package.json' and '/home/[user]/public_html/new_site/frontend/package.json' are the same file /bin/cp: 'frontend/pages' and '/home/[user]/public_html/new_site/frontend/pages' are the same file /bin/cp: 'frontend/postcss.config.js' and '/home/[user]/public_html/new_site/frontend/postcss.config.js' are the same file /bin/cp: 'frontend/static' and '/home/[user]/public_html/new_site/frontend/static' are the same file Task completed with exit code 1. 1576778783.2155 Build completed with exit code 1
There doesn't seem to be any mention of npm or even of my backend folder. Any idea where I can go from here? EDIT Thought it might also be useful to mention, there was no log path mentioned when I did my push. I found the log based on the file path you specified.0 -
Hello, The cp
command is failing with an error that is preventing the other commands from running. Based on the error, your git repo is directly in/home/user/public_html/new_site/
-- thecp
command is failing because you're trying to copy files onto themselves. If you're deploying directly to that directory, you don't need to copy the files as well. What happens if you get rid of the first 4 or 5 tasks, leaving you with just thenpm
commands?0 -
Hi HB, I've modified the .cpanel.yml file, leaving only the following: --- deployment: tasks: - npm run build --prefix /home/vksappc/public_html/new_site/backend - npm run start --prefix /home/vksappc/public_html/new_site/backend
This does not seem to be working either. However, there is no longer a log created when I push my code to cPanel. The only logging information I have is what is written to the terminal when I run git push:Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Delta compression using up to 8 threads Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 366 bytes | 366.00 KiB/s, done. Total 3 (delta 1), reused 0 (delta 0) remote: Recieved update on checked-out branch, queueing deployment. remote: --- remote: apiversion: 3 remote: func: create remote: module: VersionControlDeployment remote: result: remote: data: ~ remote: errors: ~ remote: messages: ~ remote: metadata: {} remote: remote: status: 1 remote: warnings: ~ To ssh://[ip]:[port]/home/[user]/public_html/new_site e7e35bac..cca785dc HEAD -> master Branch 'master' set up to track remote branch 'master' from 'cpanel'.
0 -
Hello, Is your .cpanel.yml
file in the top directory of your git repo? Also, does this repository show up in the cPanel " "Git" Version Control" interface in the cPanel user account?0 -
Hi HB, I believe that would be a yes to both questions. In the Git Version Control interface, I have a repository pointing to /home/[user]/public_html/new_site And the .cpanel.yml file is in that directory, along with the folders /backend and /frontend, each containing their respective code and being the folders inside which I would like to run "npm start", using the --prefix command. 0 -
Hello, Without access to the system, it's hard to say what the problem may be. Would you please submit a ticket using the link in my signature? 0 -
Hi HB, Sure. However, in order to do that, I will have to wait for my system administrator to be back from vacation next week as I do not have access to the proper account needed to submit the support ticket. Thanks 0 -
Hi HB, Small update actually. Playing around with it and reinserting the "Export PATH" line, I managed to get it to work! Partially... Here is what I have: --- deployment: tasks: - export PATH=/home/vksappc/bin/:$PATH - npm run build --prefix /home/vksappc/public_html/new_site/backend - npm run start --prefix /home/vksappc/public_html/new_site/backend - npm run build --prefix /home/vksappc/public_html/new_site/frontend - npm run start --prefix /home/vksappc/public_html/new_site/frontend
And this really does work, the first time. If I run it again however, it breaks at " - npm run start --prefix /home/vksappc/public_html/new_site/backend" because the port is already in use, because the app is running. So I would need to somehow kill the app on that port before building and running it again, otherwise the new build on the backend will never go live and the frontend script won't happen at all. Any tips? Thanks again!0
Please sign in to leave a comment.
Comments
13 comments