mibexsoftware / bamboo-plan-dsl-plugin

Configuration as code with a Groovy-based DSL or YAML for Atlassian Bamboo.
https://marketplace.atlassian.com/plugins/ch.mibex.bamboo.plandsl/
Other
40 stars 16 forks source link

Example using ArtifactDownloaderTask #9

Closed jdonofrio728 closed 7 years ago

jdonofrio728 commented 7 years ago

Any chance that an example using the ArtifactDownloaderTask could be provided?

mrueegg commented 7 years ago

Sure! Here is how you define the artifact downloader task in your task section:

tasks {
    artifactDownload() {
        description 'Download release content'
        artifact('my JAR') {
        }
    }
}

In this example, I reference an artifact called my JAR which is provided somewhere else in my build. Probably, you want to reference it from another build job where it can be defined as follows:

job(key: 'JAR', name: 'Build JAR') {
  artifacts {
    definition(name: 'my JAR', copyPattern: '**/*.jar') {
      location 'target'
      shared true
   }
}

Does that help you?

jdonofrio728 commented 7 years ago

Hey thanks for the quick update! It does help. Would the code be different if you need to download an artifact produced by a job in another plan?

jdonofrio728 commented 7 years ago

Also, I'm getting an error while running the following groovy code which is based off of your example given above:

bamboo-dsl-error.txt

test.groovy

project(key: 'TEST2', name: 'Artifact tests') {
  plan(key: 'ENV', name: 'Environments'){
    stage(key: 'DEV', name: 'Run this first'){
      job(key: 'AAA', name: 'Stuff'){
        tasks{
          script(){
            inline{
              interpreter ScriptInterpreter.LEGACY_SH_BAT
              scriptBody '''
echo "Hello Artifact" > artifact/message.txt
'''
            }
          }
        }
        artifacts{
          definition(name: 'message', copyPattern: '*.txt'){
            location 'artifact/'
            shared true
          }
        }
      }
    }
    stage(key: 'BLAH', name: 'Do me second'){
      job(key: 'DEVDEP', name: 'Dev Deploy'){
        tasks{
          artifactDownload(){
            artifact('message'){}
          }
          script(){
            inline{
              interpreter ScriptInterpreter.LEGACY_SH_BAT
              scriptBody '''
echo "Deploying to Dev based on my artifact from the package"
echo
cat *.txt
'''
            }
          }
        }
      }
    }
  }
}
mrueegg commented 7 years ago

Hi,

Thanks for your example DSL. With it, I was able to reproduce this problem. Artifact downloading in a plan from a different stage currently results in this bug.

I've fixed this now and will spin a new release tomorrow. This new release will also support artifact downloading from different plans. We will introduce a new field sourcePlanKey in the downloader task so that you can specify a different plan to download your artifact from.

I'll reply here once the new release is available in the Marketplace.

mrueegg commented 7 years ago

Fixed with release 1.4.1. This release also contains the new sourcePlanKey field. Please update your plug-in installation and try again.

jdonofrio728 commented 7 years ago

Thanks @mrueegg ! I'll up with the latest release soon and try again.