Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. pipeline {
  2. agent {
  3. label "jenkins-go"
  4. }
  5. environment {
  6. ORG = 'vfarcic'
  7. APP_NAME = 'go-demo-6'
  8. CHARTMUSEUM_CREDS = credentials('jenkins-x-chartmuseum')
  9. }
  10. stages {
  11. stage('CI Build and push snapshot') {
  12. when {
  13. branch 'PR-*'
  14. }
  15. environment {
  16. PREVIEW_VERSION = "0.0.0-SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER"
  17. PREVIEW_NAMESPACE = "$APP_NAME-$BRANCH_NAME".toLowerCase()
  18. HELM_RELEASE = "$PREVIEW_NAMESPACE".toLowerCase()
  19. }
  20. steps {
  21. container('go') {
  22. dir('/home/jenkins/go/src/github.com/vfarcic/go-demo-6') {
  23. checkout scm
  24. sh "make unittest"
  25. sh "make linux"
  26. sh "export VERSION=$PREVIEW_VERSION && skaffold build -f skaffold.yaml"
  27. sh "jx step post build --image $DOCKER_REGISTRY/$ORG/$APP_NAME:$PREVIEW_VERSION"
  28. }
  29. dir('/home/jenkins/go/src/github.com/vfarcic/go-demo-6/charts/preview') {
  30. sh "make preview"
  31. sh "jx preview --app $APP_NAME --dir ../.."
  32. }
  33. }
  34. }
  35. }
  36. stage('Build Release') {
  37. when {
  38. branch 'master'
  39. }
  40. steps {
  41. container('go') {
  42. dir('/home/jenkins/go/src/github.com/vfarcic/go-demo-6') {
  43. checkout scm
  44.  
  45. // ensure we're not on a detached head
  46. sh "git checkout master"
  47. sh "git config --global credential.helper store"
  48. sh "jx step git credentials"
  49.  
  50. // so we can retrieve the version in later steps
  51. sh "echo \$(jx-release-version) > VERSION"
  52. sh "jx step tag --version \$(cat VERSION)"
  53. sh "make build"
  54. sh "export VERSION=`cat VERSION` && skaffold build -f skaffold.yaml"
  55. sh "jx step post build --image $DOCKER_REGISTRY/$ORG/$APP_NAME:\$(cat VERSION)"
  56. }
  57. }
  58. }
  59. }
  60. stage('Promote to Environments') {
  61. when {
  62. branch 'master'
  63. }
  64. steps {
  65. container('go') {
  66. dir('/home/jenkins/go/src/github.com/vfarcic/go-demo-6/charts/go-demo-6') {
  67. sh "jx step changelog --version v\$(cat ../../VERSION)"
  68.  
  69. // release the helm chart
  70. sh "jx step helm release"
  71.  
  72. // promote through all 'Auto' promotion Environments
  73. sh "jx promote -b --all-auto --timeout 1h --version \$(cat ../../VERSION)"
  74. }
  75. }
  76. }
  77. }
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement