Files
cje-crash-course/exercises/12-basic-jenkinsfile/solution/solution.md
Benjamin Muschko 248499c8f6 Initial commit
2019-11-17 16:40:48 -07:00

862 B

Solution

Create a new job.

New Job

Configure the appropriate SCM.

Job SCM

Install the Go plugin.

Go Plugin

Configure a Go runtime as global tool.

Go Global Tool

The main.go file could similar to the one below.

package main

import "fmt"

func main() {
    fmt.Println("hello world")
}

The final Jenkinsfile looks similar to the solution below.

pipeline {
    agent any
    tools {
        go 'go-1.12'
    }
    environment {
        GO111MODULE = 'on'
    }
    stages {
        stage('Build') {
            steps {
                sh 'go build'
            }
        }
    }
}

A build of the job installs the Go runtime and executes the build step.

Declarative Pipeline