Usage Examples
Basic CI/CD Example with shell Agent
Create a configuration .yaml file in your project root:
Default filename is
gitflic-ci.yaml. See the gitflic-ci.yaml reference for detailed keyword descriptions
stages:
  - test
  - build
  - release
test job:
  stage: test
  scripts:
    - echo "Running tests for branch $CI_COMMIT_REF_NAME"
build job:
  stage: build
  scripts:
    - echo "Building project with artifacts"
    - mkdir artifact/
    - echo "I'm an artifact" > artifact/artifact.txt
  artifacts:
    name: artifact
    paths:
      - artifact/
release job:
  stage: release
  when: manual
  scripts:
    - echo "Creating release"
  needs: ["test job", "build job"]
A successfully executed pipeline might look like this:
Example of Deploying Code to Remote Server via CI/CD
Using CI/CD with Docker Agent
This example is for agents running in Docker mode. For shell mode agents, you can provide remote server access via pre-configured private keys.
- SSH keys are required for remote server access. Create new keys following these instructions or use existing ones.
  Add the public key to your target server by copying ~/.ssh/id_ed25519.pubcontents to the server'sauthorized_keysfile. In project CI/CD settings, create these variables:
- SSH_KEYwith private key
- SSH_PORTwith connection port
- SERVER_USERwith username
- SERVER_IPwith server address
 * Create a
* Create a gitflic-ci.yaml file in your project root:
image: ubuntu:latest
stages:
  - build
job 1:
  stage: build
  tags:
    - docker
  when: manual
  scripts:
    - mkdir test
    - echo "Hello, world!" > test/text.txt
    - apt-get update -y
    - apt-get install openssh-client -y
    - |
      eval $(ssh-agent -s)
      echo "$SSH_KEY" | tr -d '\r' | ssh-add -
      ssh -o "StrictHostKeyChecking=no" -p $SSH_PORT $SERVER_USER@$SERVER_IP "mkdir -p ~/example/"
      scp -o "StrictHostKeyChecking=no" -P $SSH_PORT test/text.txt $SERVER_USER@$SERVER_IP:~/example/
  artifacts:
    name: file-create
    paths:
      - test
Command Explanations
| Command | Description | 
|---|---|
| apt-get update -yandapt-get install openssh-client -y | Required for SSH package installation. Can be skipped if container/shell agent already has sshpackage | 
| eval $(ssh-agent -s) | Starts ssh-agent | 
| echo "$SSH_KEY" \| tr -d '\r' \| ssh-add - | Adds key via ssh-agent | 
| ssh -o "StrictHostKeyChecking=no" -p $SSH_PORT -i id_ed25519 $SERVER_USER@$SERVER_IP "mkdir -p ~/example/" | Executes remote directory creation command. -o "StrictHostKeyChecking=no"automatically accepts RSA keys. | 
| scp -o "StrictHostKeyChecking=no" -P $SSH_PORT -i id_ed25519 file/file1.txt $SERVER_USER@$SERVER_IP:~/example/ | Transfers files to remote server | 
Variable Descriptions
| Parameter | Description | 
|---|---|
| $SSH_KEY | Contains private key value. | 
| $SSH_PORT | SSH connection port (e.g., 22). | 
| $SERVER_USER | SSH username (e.g., ivan). | 
| SERVER_IP | Server IP address (e.g., 158.162.17.149). | 
Automatic Translation!
This page was automatically translated. The text may contain inaccuracies
