How to generate YAML Specs for any-task configurations
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
The YAML Specs export does not show configuration maps for certain any-task
plugin tasks from apps, such as the Generic Artifactory Deploy Task from the Artifactory for Bamboo app.
This article will use this task as an example.
Environment
This applies to Bamboo versions 7.2 and above, which have the any-task command in YAML.
Diagnosis
When the plan is exported as YAML Specs, the any-task
command will show as:
- any-task:
plugin-key: org.jfrog.bamboo.bamboo-artifactory-plugin:artifactoryGenericTask
configuration: {}
Cause
The Specs exporter included in the Artifactory plugin does not include YAML configurations.
Solution
Export the plan as Java Specs and convert the Java to YAML
The Java Specs export will show the Task would export as:
new AnyTask(new AtlassianModule("org.jfrog.bamboo.bamboo-artifactory-plugin:artifactoryGenericTask"))
.configuration(new MapBuilder()
.put("artifactory.generic.publishBuildInfo", "")
.put("artifactory.generic.username", "")
.put("artifactory.generic.specSourceChoice", "file")
.put("artifactory.task.buildNumber", "${bamboo.buildNumber}")
.put("deployer.sharedCredentials", "Test")
.put("deployer.overrideCredentialsChoice", "sharedCredentials")
.put("artifactory.task.buildName", "${bamboo.buildPlanName}")
.put("artifactory.generic.resolveRepo", "")
.put("artifactory.generic.deployPattern", "argh")
.put("artifactory.generic.envVarsExcludePatterns", "*password*,*secret*,*security*,*key*")
.put("builder.artifactoryGenericBuilder.artifactoryServerId", "0")
.put("artifactory.generic.file", "")
.put("resolver.overrideCredentialsChoice", "")
.put("artifactory.generic.useSpecsChoice", "legacyPatterns")
.put("artifactory.generic.includeEnvVars", "true")
.put("artifactory.generic.artifactSpecs", "")
.put("artifactory.generic.password", "/* SENSITIVE INFORMATION */")
.put("artifactory.generic.jobConfiguration", "{\n \"files\": [\n{\n \"pattern\":\".\", \n \"target\":\"/\"\n }\n ]\n}")
.put("baseUrl", "http://bamboo:8085")
.put("artifactory.generic.envVarsIncludePatterns", "")
.put("artifactory.generic.resolvePattern", "")
.put("builder.artifactoryGenericBuilder.deployableRepo", "blah")
.put("captureBuildInfo", "true")
.put("resolver.sharedCredentials", "")
.put("buildInfoAggregation", "true")
.build())))
This could be converted to YAML as below. Any line that is not included will use the default.
- any-task:
plugin-key: org.jfrog.bamboo.bamboo-artifactory-plugin:artifactoryGenericTask
configuration:
artifactory.generic.publishBuildInfo: true
artifactory.generic.specSourceChoice: jobConfiguration
artifactory.task.buildNumber: ${bamboo.buildNumber}
deployer.overrideCredentialsChoice: noOverriding
artifactory.task.buildName: ${bamboo.buildPlanName}
artifactory.task.envVarsExcludePatterns: "*password*,*secret*,*security*,*key*"
builder.artifactoryGenericBuilder.artifactoryServerId: 0
artifactory.generic.useSpecsChoice: specs
artifactory.generic.includeEnvVars: true
artifactory.generic.jobConfiguration:
|-
{
files: [
{
pattern: ".",
target: "/"
}
]
}
baseUrl: http://bamboo:8085
captureBuildInfo: true
buildInfoAggregation: true