Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wjimenez5271/d86144b6f1c21bddc609616b94805dcf to your computer and use it in GitHub Desktop.
Save wjimenez5271/d86144b6f1c21bddc609616b94805dcf to your computer and use it in GitHub Desktop.
# Creating a Rancher CI Pipeline
# Creating a Rancher CI Pipeline
In this lab we will create an automated CI pipeline using Rancher's automated CI tooling. We will need a Github account (personal or enterprise) for this lab,but you can alternatively use Bitbucket or Gitlab.
1. Setup Authorization with Github
In the Rancher UI, navigate to the project of your choice, and then select the "Pipelines" tab (under the main menu bar). Then proceed to select "setup github authorization" . You will be take to a Github page that will require you to sign in and authorize your Rancher install to make API calls.
2. For purposes of this lab, we're going to use an existing repo that has code in it already. Pipelines require the repo to exist in the github account you have connected, so we are going to fork the repo to our personal/corporate account. Go to rancher/rancher/pipeline-example-go and then click fork
2. Next back in the Rancher UI under Pipelines, select create "Configure Repositories", and then enable the pipeline-example-go repo we previously forked from the list of repos in your account.
3. Next create a new build stage called "Build". Within this stage create a new step and select the option "Run Script". Using the golang image, add the following lines to the script:
```
mkdir -p /go/src/github.com/rancher
ln -s `pwd` /go/src/github.com/rancher/pipeline-example-go
cd /go/src/github.com/rancher/pipeline-example-go
go build -o bin/hello-server
go test -cover
```
4. Next, add another build stage, call this one "Publish". Inside this stage select a "Build and Publish" step. For the Dockerfile path, there is a Dockerfile in the repo so we can use `./Dockerfile`. For the Image name we can use `example-helloserver:${CICD_EXECUTION_SEQUENCE}`
5. Now add a final stage called "Deploy". Here we want to use the "Deploy YAML" step and pass the path to our deployment YAML that is also in the repo: `./deployment.yaml`
6. Now our pipeline is complete. We can manually run a build from the right-hand options menu, or we can make a commit to our repo to trigger a build. Once it builds it should deploy it to our environment.
Verify the build logs in the build details view, and check that the deployment shows up in your workloads tab.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment