-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes terraform-google-modules#2: Pull useful example code into submo…
…dule terraform-google-modules#2 Added submodule for artifacts.
- Loading branch information
Showing
9 changed files
with
217 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Artifact storage module | ||
|
||
This provisions GCS bucket for artifacts and optionally renders jobs with automatic artifact upload. | ||
|
||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|:----:|:-----:|:-----:| | ||
| project_id | The project ID to deploy to | string | - | yes | | ||
| jobs | A list of Jenkins jobs to populate | list | [] | no | | ||
| jobs_count | Amount of jobs to populate | number | 0 | no | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| artifact_bucket | Artifact bucket name | | ||
| jobs | List of rendered jobs | | ||
|
||
[^]: (autogen_docs_end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Copyright 2019 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
resource "google_storage_bucket" "artifacts" { | ||
name = "${var.project_id}-jenkins-artifacts" | ||
project = var.project_id | ||
force_destroy = true | ||
} | ||
|
||
data "local_file" "artifact_upload_job_template" { | ||
filename = "${path.module}/templates/artifact_upload_job.xml.tpl" | ||
} | ||
|
||
data "template_file" "artifact_upload_job" { | ||
count = var.jobs_count | ||
|
||
template = data.local_file.artifact_upload_job_template.content | ||
|
||
vars = { | ||
project_id = var.project_id | ||
build_artifact_bucket = google_storage_bucket.artifacts.url | ||
|
||
job_name = var.jobs[count.index].name | ||
job_builders = join("\n", var.jobs[count.index].builders) | ||
} | ||
} | ||
|
||
data "null_data_source" "jobs" { | ||
count = var.jobs_count | ||
|
||
inputs = { | ||
name = var.jobs[count.index].name | ||
manifest = data.template_file.artifact_upload_job[count.index].rendered | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright 2018 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
output "artifact_bucket" { | ||
description = "Artifact bucket name" | ||
value = google_storage_bucket.artifacts.name | ||
} | ||
|
||
output "jobs" { | ||
description = "List of rendered jobs" | ||
value = data.null_data_source.jobs.*.outputs | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<project> | ||
<actions/> | ||
<description></description> | ||
<description>Job ${job_name}</description> | ||
<keepDependencies>false</keepDependencies> | ||
<properties/> | ||
<scm class="hudson.scm.NullSCM"/> | ||
|
@@ -13,10 +13,7 @@ | |
<triggers/> | ||
<concurrentBuild>true</concurrentBuild> | ||
<builders> | ||
<hudson.tasks.Shell> | ||
<command>echo "hello world from testjob" | ||
env > build-log.txt</command> | ||
</hudson.tasks.Shell> | ||
${job_builders} | ||
</builders> | ||
<publishers> | ||
<com.google.jenkins.plugins.storage.GoogleCloudStorageUploader plugin="[email protected]"> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright 2019 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
variable "project_id" { | ||
description = "The project ID to deploy to" | ||
type = string | ||
} | ||
|
||
variable "jobs" { | ||
description = "A list of Jenkins jobs to populate" | ||
default = [] | ||
|
||
type = list(object({ | ||
name = string | ||
builders = list(string) | ||
})) | ||
} | ||
|
||
variable "jobs_count" { | ||
description = "Amount of jobs to populate" | ||
type = number | ||
default = 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters