Create an empty versatile template for CI
Release notes
Problem to solve
When a first-time user starts writing their first pipeline configuration they see an empty blank page with no guidance on how to proceed. GitLab has robust capabilities for pipeline authoring however those are not exposed through our UI. It's very difficult to get started, especially for novice CI users. The path to the first green pipeline isn't easy.
Intended users
User experience goal
Provide a basic default template that illustrates GitLab CI yaml syntax and core functionality. Make it easy to see the pipeline in action by providing a versatile configuration that will run successfully the first time.
Proposal
We should provide new users with a template which shows some of the most basic capabilities, as well as provides additional guidance on how the syntax works and how to customize different settings. But the template needs to be versatile enough that the pipeline will run successfully the first time.
That template would appear in the Pipeline Editor by default for users who don't have a CI configuration, so they can get started easier.
Template Name: Getting started
# This is a sample GitLab CI/CD configuration file
# It should run without any modifications, and shows
# a basic CI/CD workflow when added to a project.
stages: # List of stages for jobs, and their order of execution
- build
- test
- deploy
# The default docker image for jobs to use.
image: alpine
# Global defaults apply to all jobs
# See: https://docs.gitlab.com/ee/ci/yaml/#variables
default:
before_script:
- echo "this command runs before every job"
retry: 2 # If a job fails, automatically retry it up to two times.
# CI/CD variables defined at the global level are available to all jobs.
# See https://docs.gitlab.com/ee/ci/yaml/#variables
variables:
DEPLOY_APP: true
DEPLOY_PATH: "example/path"
# Jobs load in a docker container with the docker image specified above, but it
# can be specified in the job too. The script commands run as CLI commands
# within the container.
check_dependencies: # This is a job. The name does not need to be predefined.
stage: build # Specify which stage the job runs in.
script: # Run the following CLI commands in the container.
- echo "This job checks dependencies."
build_code:
stage: build
image: busybox # Use a different image than the one defined globally.
script:
- echo "Compiling the code..."
- echo "The compiled artifact" > compiled.txt
artifacts:
paths:
- compiled.txt # upload this file as artifact
unit_tests: # Jobs in this test stage only run after jobs in the build stage
stage: test # complete successfully.
script:
- echo "Running unit tests..."
- echo "Code coverage is 90%"
coverage: '/Code coverage: \d+%/' # Collect code coverage results from the job's log.
integration_tests:
stage: test
script:
- echo "This job tests something. It will only run when all jobs in the"
- echo "build stage are complete."
- echo "tests_run 254" > metrics.txt
artifacts:
reports:
metrics: metrics.txt # Display these metrics in the merge request.
system_tests: # This demonstrates a job failure, unless the last line is uncommented.
stage: test
script: # Artifacts from jobs in previous stages are automatically
- cat compiled.txt # downloaded and accessible.
- echo "Run system tests... which will fail!"
- exit 1
# allow_failure: true # Uncomment to allow the job to fail without stopping the pipeline.
deploy_app: # Conditionally run this job based on variables values.
stage: deploy
rules:
- if: '$RUN_SYSTEM_TESTS == "true"' # This job only runs if the variable = "true".
script:
- echo "Deploy to $DEPLOY_PATH" # Use variables within CLI script commands
# Other jobs with more advanced features: needs, rules, variables, include, etc.
# ...
Further details
We can enhance that feature and provide smart suggestion in a snippet for different examples such as rules: e.g. run this comment for merge request on master branch only and provide the relevant if statement. (probably out of scope for MVC).
Documentation
What does success look like, and how can we measure that?
What is the type of buyer?
Links / references
/cc @nadia_sotnikova
This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.