Today we will setup a basic pipeline that executes 2 jobs, one using a alpine container that runs a couple of shell commands, and the other job will be using a Golang container to build and execute a golang app. I will also be experimenting with auto trigger, that will trigger the pipeline to run its jobs every 60 seconds.
resources:-name:container-resourcetype:timesource:interval:60mjobs:-name:my-alpine-jobplan:-get:container-resourcetrigger:true-task:vanilla-alpine-tasksparams:OWNER:ruanconfig:platform:linuximage_resource:type:docker-imagesource:repository:alpinetag:edgerun:path:/bin/shargs:--c-|apk update > /dev/nullapk upgrade > /dev/nullapk add curl > /dev/nullecho "Public IP is: `curl -s http://ip.ruanbekker.com`"echo "Hostname is: $HOSTNAME"echo "Owner is: $OWNER"echo foo > /tmp/word.txtexport MAGIC_WORD=`cat /tmp/word.txt`echo "Magic word is $MAGIC_WORD"cat > app.sh << EOF#!/usr/bin/env shecho "Hello, World!"EOFchmod +x app.shecho "Shell Script Executing:"./app.sh-name:my-golang-jobplan:-get:container-resourcetrigger:true-task:golang-tasksparams:OWNER:jamesconfig:platform:linuximage_resource:type:docker-imagesource:repository:golangtag:'1.6'run:path:/bin/shargs:--c-|echo "User: `whoami`"echo "Go Version: `go version`"echo "Hostname is: $HOSTNAME"echo "Owner is: $OWNER"echo bar > /tmp/word.txtexport MAGIC_WORD=`cat /tmp/word.txt`echo "Magic word is $MAGIC_WORD"cat > app.go << EOFpackage mainimport "fmt"func main() {fmt.Println("Hello, World!")}EOFgo build app.goecho "Go App Executing:"./app
Login to Concourse:
Logon to concourse and set your target:
1234567
$ fly -t ci login --concourse-url=http://10.20.30.40:8080
logging in to team 'main'username: admin
password:
target saved
List your targets:
123
$ fly targets
name url team expiry
ci http://10.20.30.40:8080 main Sat, 25 Nov 2017 23:30:55 UTC
Apply Configuration
Apply your Configuration:
123456789
$ fly -t ci set-pipeline -p bash-and-golang -c bash-and-golang.yml
apply configuration? [yN]: y
pipeline created!
you can view your pipeline here: http://10.20.30.40:8080/teams/main/pipelines/bash-and-golang
the pipeline is currently paused. to unpause, either:
- run the unpause-pipeline command - click play next to the pipeline in the web ui
Unpause
Unpause your Pipeline:
12
$ fly -t ci unpause-pipeline -p bash-and-golang
unpaused 'bash-and-golang'
Trigger
Trigger your first job, which will be the Alpine job:
12
$ fly -t ci trigger-job --job bash-and-golang/my-alpine-job
started bash-and-golang/my-alpine-job #2
Trigger your second job, which will be the Golang job:
12
$ fly -t ci trigger-job --job bash-and-golang/my-golang-job
started bash-and-golang/my-golang-job #2
Remember, we can also monitor the output from the shell:
$ fly -t ci trigger-job --job bash-and-golang/my-golang-job --watch
started bash-and-golang/my-golang-job #3initializing
running /bin/sh -c echo"User: `whoami`"echo"Go Version: `go version`"echo"Hostname is: $HOSTNAME"echo"Owner is: $OWNER"echo bar > /tmp/word.txt
export MAGIC_WORD=`cat /tmp/word.txt`echo"Magic word is $MAGIC_WORD"cat > app.go << EOFpackage mainimport "fmt"func main() { fmt.Println("Hello, World!")}EOFgo build app.go
echo"Go App Executing:"./app
User: root
Go Version: go version go1.6.4 linux/amd64
Hostname is:
Owner is: james
Magic word is bar
Go App Executing:
Hello, World!
succeeded
And you can also debug the job by dropping yourself into the container by using hijack:
1
$ fly -t ci hijack --job bash-and-golang/my-golang-job