Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bigorangemachine/b45a4b1634af094cbc0a835e0d590e8f to your computer and use it in GitHub Desktop.
Save bigorangemachine/b45a4b1634af094cbc0a835e0d590e8f to your computer and use it in GitHub Desktop.
Development process Concourse Resource type

Readme.md is WIP (living document)

Install

Install docker

Grab the concourse tutorial

mkdir docker-concourse
cd docker-concourse
wget https://concourse-ci.org/docker-compose.yml
docker-compose up -d # remove -d to see logs
open http://127.0.0.1:8080
cd -

Install Fly CLI

mkdir fly-cli-client
cd fly-cli-client
wget https://github.com/concourse/concourse/releases/download/v3.13.0/fly_darwin_amd64
mv fly_darwin_amd64 fly
sudo chmod +x fly
install fly /usr/local/bin

Connect to your localhost CI

fly -t tutorial login --concourse-url http://127.0.0.1:8080
fly -t tutorial sync
fly -t tutorial set-pipeline -c examples/init/pipeline.yml -p hello-world
fly -t tutorial unpause-pipeline -p hello-world

Stop your Docker

cd docker-concourse; docker-compose down; cd -

Build Docker

Setup for the first time

docker build . #build the docker file
docker image ls # get the docker sha
docker run -i -t <DOCKER-IMAGE-ID> /bin/ash # run interactive
docker build -t my-resource-type:v1 .
docker ps -a # get the docker container id
docker commit -m "first commit" -a "your-username" <DOCKER-CONTAINER-ID> your-username/my-resource-type
docker push your-username/my-resource-type
docker tag <DOCKER-IMAGE-ID> your-username/my-resource-type:v1
docker push your-username/my-resource-type:v1

Build Dockerfile

docker build .

then test your changes

docker image ls # get the docker sha
docker run -i -t <DOCKER-IMAGE-ID> /bin/ash # run interactive for alpine (instead of bash for other linux)

Type exit to exit docker interactive (-i -t).

Debug from docker

Run in interactive mode docker run -i -t <DOCKER-IMAGE-ID> /bin/ash then from that terminal you can test inputs printf "{\"only\":\"a-test\"}"|./check

Debug from fly/hijack/intercept

fly -t tutorial intercept --check hello-world/my-pipeline

Using Webhooks

/api/v1/teams/main/pipelines/[PIPELINE-NAME]/resources/[RESOURCE-NAME]/check/webhook?webhook_token=[RANDOM-TOKEN]

The pipeline.yml

resources:
  - name: git-website-develop
    type: git
    webhook_token: [RANDOM-TOKEN]
    source:
      uri: git@github.com:USER/REPO
      branch: develop
      private_key: ((github-private-key))

Setup Pipeline Resource

Configure the Resource type

resource_types:
...
  - name: my-resource-type
    type: docker-image
    source:
      repository: your-username/my-resource-type
...

Configure the Resource for a webhook

resources:
...
  - name: my-resource-instance
    type: my-resource-type
    webhook_token: [RANDOM-TOKEN]
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment