diff --git a/.gitignore b/.gitignore index 38f650bd..5750b816 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ bin .idea - +release/ diff --git a/Jenkinsfile b/Jenkinsfile index 95df4acd..06661cf0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,32 +1,38 @@ -#!/usr/bin/groovy -@Library('github.com/fabric8io/fabric8-pipeline-library@master') -def dummy -goNode{ - dockerNode{ - ws{ - if (env.BRANCH_NAME.startsWith('PR-')) { - def buildPath = "/home/jenkins/go/src/github.com/jenkins-x/jx-release-version" - sh "mkdir -p ${buildPath}" - - dir(buildPath) { - container(name: 'go') { - stage ('build binary'){ - // it looks like using checkout scm looses the tags - sh "git clone https://github.com/jenkins-x/jx-release-version ." - sh "git fetch origin pull/${env.CHANGE_ID}/head:test" - sh "git checkout test" - sh "make" +pipeline { + agent { + label "jenkins-go" + } + stages { + stage('CI Build and Test') { + when { + branch 'PR-*' + } + steps { + dir ('/home/jenkins/go/src/github.com/jenkins-x/jx-release-version') { + checkout scm + container('go') { + sh "make" + sh "./bin/jx-release-version-linux" + } } } } - } else if (env.BRANCH_NAME.equals('master')) { - def v = goRelease{ - githubOrganisation = 'rawlingsj' - dockerOrganisation = 'fabric8' - project = 'jx-release-version' + + stage('Build and Release') { + environment { + GH_CREDS = credentials('jenkins-x-github') + } + when { + branch 'master' + } + steps { + dir ('/home/jenkins/go/src/github.com/jenkins-x/jx-release-version') { + checkout scm + container('go') { + sh "GITHUB_ACCESS_TOKEN=$GH_CREDS_PSW make release" + } + } + } } - } } - } } - diff --git a/Makefile b/Makefile index fbb5da9c..325ea609 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ NAME := jx-release-version ORG := jenkins-x ROOT_PACKAGE := main.go -VERSION := 1.0.4 +VERSION := $(shell jx-release-version) GO := GO15VENDOREXPERIMENT=1 go REVISION := $(shell git rev-parse --short HEAD 2> /dev/null || echo 'unknown')