There is such task in my .gitlab-ci.yml
deploy_all:
stage: deploy
script:
- cp project/target/jnlp/* html/jnlp/
tags:
- client:deploy-all
Everything works fine except unnecessary git repository fetching. Below is extract from runner's log
Running with gitlab-ci-multi-runner 9.1.0 (0118d89)
...
Fetching changes...
HEAD is now at 8dfc104 Update .gitlab-ci.yml
...
Job succeeded
The repository is not needed here because I need only artifacts from other tasks. Is it possible to disable this behaviour?
I found the solution:
upgraded gitlab to version 10.x, manual is here https://docs.gitlab.com/runner/install/linux-repository.html
disabled git checkout in the build script (by adding variables)
deploy_all:
variables:
GIT_STRATEGY: none
GIT_CHECKOUT: "false"
stage: deploy
script:
- cp project/target/jnlp/* html/jnlp/
tags:
- client:deploy-all
Related
I can run script for build my project in gitlab-ci.yaml config.Is there a way let pipline download the file output by build script from browser, then i can find it in my computer?
You could create a job artifact from the output of commands from your pipeline (like your build script), assuming you have redirected said output in a file.
You can then download job artifacts by using the GitLab UI or the API.
Using the GitLab CLI glab:
glab ci artifact <refName> <jobName> [flags]
# example
glab ci artifact main build
This is my ci config, to download build-files on Gitlab UI via artifact field.
stages:
- build
.build-base:
stage: build
script:
- cd dev/${APP_PATH}
- yarn ${BUILD_SCRIPT}
when: manual
after_script:
- mv dev/${APP_PATH}/dist ./${APP_OUTPUT_NAME}
artifacts:
paths:
- ./${APP_OUTPUT_NAME}
expire_in: 2 week
name: ${APP_OUTPUT_NAME}_${CI_JOB_ID}
tags:
- kube-runner
order_workbench_sit_build:
extends: .build-base
variables:
APP_PATH: 'order-management'
BUILD_SCRIPT: 'build:sit'
APP_OUTPUT_NAME: 'order_workbench_sit'
order_workbench_build:
extends: .build-base
variables:
APP_PATH: 'order-management'
BUILD_SCRIPT: 'build'
APP_OUTPUT_NAME: 'order_workbench'
My goal is to create Gitlab yml file in order to automatically merge code from release to master branch which will be run on a schedule (once a week)
Here is my .gitlab-ci.yml:
image: "python:3.8"
stages:
- build
- test
- release
Build:
stage: build
script:
- <some code here>
Test:
stage: test
script:
- <some code here>
job:on-schedule:
stage: release
only:
- schedules
script:
- git config --global user.email myEmail#gmail.com
- git config --global user.name "myUserName"
- git checkout release
- git checkout master
- git merge release
But I'm getting the following error:
error: pathspec 'release' did not match any file(s) known to git
Cleaning up file based variables
00:00
ERROR: Job failed: exit code 1
. I'd appreciate it if you have any ideas on how to fix that.
By default, gitlab-ci does a shallow clone, and so the error you're seeing of:
error: pathspec 'release' did not match any file(s) known to git
is accurate because the release branch does not exist locally on the runner.
To resolve this, you can just update the lines to:
- git checkout origin/release
- git checkout origin/master
which will pull the latest branches from the repository directly instead.
So I'm trying to learn deployement with Azure Devops. I have this Angular app sitting in Gitlab which already has a CI/CD pipeline with jenkins to kubernetes cluster. So i was thinking to do the same with Azure Devops via YAML. Which is not possible according to Azure docs directly from gitlab.
So what i'm trying to do is create CI pipeline from github which takes checkout from gitlab UI repo and build it for deployement.
I have created a Repository Resource in my below pipeline YAMl file. Azure give me error saying:
Repository JpiPipeline references endpoint https://gitlab.com/myusername/myUiRepo.git which does not exist or is not authorized for use
trigger:
- master
resources:
repositories:
- repository: UiPipeline. #alias
type: git
name: repository_name
# ref: refs/heads/master # ref name to use; defaults to 'refs/heads/master'
endpoint: https://#gitlab.com/myusername/myUiRepo.git # <-- Is this possible
stages:
- stage: Checkout
jobs:
- job: Build
pool:
vmImage: 'Ubuntu-16.04'
continueOnError: true
steps:
- checkout: JpiPipeline
- script: echo "hello to my first Build"
Repository type gitlab is not support in YAML pipeline yet. The currently supported types are git, github, and bitbucket, see supported types.
The workaround to get the gitlab repo sources is to run git command inside the script tasks.
For below example Yaml pipeline:
- checkout: none to avoid checkout the github source.
Use git clone https://username:password#gitlab.com/useraccount/reponame.git to clone the gitlab repo inside a script task.
stages:
- stage: Checkout
jobs:
- job: Build
pool:
vmImage: 'Ubuntu-latest'
steps:
- checkout: none
- script: |
git clean -ffdx
git clone https://username:password#gitlab.com/useraccount/reponame.git
#if your password or username contain # replace it with %40
Your gitlab repo will be clone to folder $(system.defaultworkingdirectory)/reponame
Another workaround is to classic UI pipeline. Gitlab repo type is supported in Classic UI pipeline.
You can choose Use the classic editor to create a classic ui pipeline.
When you come to select source page. Choose other git and click Add connection to add your gitlab repo url. Then the pipeline will get the sources for your gitlab repo.
I have a project on github and some issues were solved already and it has merged pullrequests.
I try to intregrate project with circleci by adding circleci config in root of the project (I created a new branch and pushed it) .circleci/config.yml:
version: 2
jobs:
build:
working_directory: ~/circleci
docker:
- image: circleci/openjdk:8-jdk
environment:
MAVEN_OPTS: -Xmx3200m
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "pom.xml" }}
- v1-dependencies-
- run: mvn dependency:go-offline
- save_cache:
paths:
- ~/.m2
key: v1-dependencies-{{ checksum "pom.xml" }}
- run: mvn test
And I get error:
#!/bin/sh -eo pipefail
# No configuration was found in your project. Please refer to https://circleci.com/docs/2.0/ to get started with your configuration.
#
# -------
# Warning: This configuration was auto-generated to show you the message above.
# Don't rerun this job. Rerunning will have no effect.
false
Exited with code 1
It tries to run a job on a merged pullrequest.
How to make circlecie run builds from my new pullrequest in that I added circleci config?
p.s. I've tried to add circleci config into my main branch - it doesn't help.
Thanks!
CircleCI will look for a .circleci/config.yml in the branch that triggers a webhook from GitHub.
This means in a PR that the config must exist in the branch, and once merged, will be included in master.
When first added via the UI, CircleCI only looks at master, but subsequent pushes to any branch (as long as .circleci/config.yml is present in that branch) should work.
It looks like your working_directory is set incorrectly. Perhaps you mean ~/.circleci? By the way, people typically set the working directory to the root directory of the project, not the .circleci directory.
software intern here, I want to temporarily change the branch from which we build and deploy our dev, I want to set it from master to i.e. branch1. So far I've changed the default branch in the GitLab repo from master to branch1 and here is how our .gitlab-ci.yml looks like:
build:dev:
stage: build
only:
- branch1
tags:
- project-dev
script:
- docker-compose build
deploy:dev:
stage: deploy
only:
- branch1
tags:
- project-dev
script:
- docker-compose stop server
- docker-compose run server mix ecto.migrate
- docker-compose up -d
upload-to-testfairy:
stage: build
only:
- branch1
tags:
- project-simulant
script:
<doesn't really matter I guess>
I thought this would be enough, but no new jobs seem to be triggered and I can't find a way to trigger them manually either. Thanks in advance.
Ops, my bad, turns out I hadn't updated the yml file in branch1 and it still waited for changes in master in order to build and deploy, after I updated the file in branch1 it automatically started building that commit in branch1.