Quin opened 2 years ago
|
|||||
In OneDev, you can add a job and have it triggered automatically when a branch is updated (check the triggers and params section of a job). Then you can add necessary steps to do what you want, including checkout code, running commands to call ssh to deploy files to your servers etc. |
|||||
Robin Shen changed state to 'Closed' 2 years ago
|
|||||
Do you have any examples of how to do this? I'm a bit stuck in trying to figure this out. |
|||||
For instance I used below build spec to copy web site content to server via SCP, and then ssh to the server deploying the content:
Here |
|||||
Thanks for this @robin. Is there a way to set known host string and private_key as a variable stored on the project, so they're not saved into version control? |
|||||
Here private_key is defined as a project secret (check project setting / build setting / job secret). The same can be done for known host. |
|||||
Great. But how do I know what/where the directory is for the project? Here, you are copying the "public" directory to the remote/production server with SCP, right? |
|||||
When run the step command, the current directory is root of repository if checkout step runs previously. And my "public" directory is a sub folder stored in the repository. |
|||||
I've tried editing the buildspec, and this is what comes back whenever I add something other than just the version number (and I cannot commit if the version number hasn't changed):
I can still edit. Deleting the file and starting again does the same thing. |
|||||
Just copy the build spec as is to OneDev build spec editor (edit source), then switch to edit tab to edit it. |
|||||
I honestly did, and it broke when I edited it. Even re-pasting it as is didn't work, nor pasting in a new file. So I deleted it and started from scratch using the UI. There is little going in terms of documentation and understanding, because copying that made a job run, but following another guide you created involves creating an agent (which I didn't do before). |
|||||
Not sure what happens at your side. But I just copy the content, and then switch to "Edit" tab to change things. Everything works fine. Generally you should not edit the build spec source directly. |
|||||
Okay, I've basically got this working again, and I have a better understanding. However, once broke, the file needs to be deleted again and then recreated. |
|||||
@robin I am now facing an issue in creating a directory. I don't think it's a OneDev issue, but maybe you can help? I can't It fails each time I get to the Upload step, due to the permissions issue.
|
|||||
I am not familiar with rsync. It might be easier to make your script working out of OneDev first. |
|||||
Okay, I am getting somewhere. I'm rebuilding it all, and testing out all the commands. I do get this: |
Type |
Question
|
Priority |
Normal
|
Assignee |
Not assigned
|
I've got many WordPress sites that I like to automate.
I come from a Gitlab background, and their documentation for CI/CD isn't the best, and I managed to cobble together something that has managed to work. Basically, it's a bunch of SSH commands (so I don't have to manually copy and paste each line whenever I need to deploy). This ran whenever a designated branch was updated.
Now, what would be the best practice in order to do the same, and how to watch for those changes (i.e. push to Staging branch to update Staging server)? I generally don't use build or version numbers (knowing that is an option), because I don't really know how to use them effectively.
Below is what I used (and I used Gitlab variables too):