From de6148e5f1a1a143eaa252afaa7c84db5bc3a368 Mon Sep 17 00:00:00 2001 From: malcolmholmes <42545407+malcolmholmes@users.noreply.github.com> Date: Thu, 9 Dec 2021 13:09:17 +0000 Subject: [PATCH] Build: allow building releases from other repositories (#42914) * Allow building from other repositories * Upgrade grabpl * Update drone.yml --- .drone.yml | 144 +++++++++++---------------- scripts/drone/pipelines/release.star | 8 +- scripts/drone/steps/lib.star | 16 ++- 3 files changed, 75 insertions(+), 93 deletions(-) diff --git a/.drone.yml b/.drone.yml index 7d6337150fa..2b432381a58 100644 --- a/.drone.yml +++ b/.drone.yml @@ -11,7 +11,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.4/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.5/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -112,7 +112,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.4/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.5/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -337,7 +337,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.4/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.5/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -417,7 +417,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.4/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.5/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -822,7 +822,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.4/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.5/windows/grabpl.exe -OutFile grabpl.exe image: grafana/ci-wix:0.1.1 name: initialize @@ -844,6 +844,8 @@ steps: environment: GCP_KEY: from_secret: gcp_key + GITHUB_TOKEN: + from_secret: github_token PRERELEASE_BUCKET: from_secret: prerelease_bucket image: grafana/ci-wix:0.1.1 @@ -902,7 +904,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.4/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.5/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -998,7 +1000,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.4/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.5/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1372,7 +1374,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.4/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.5/windows/grabpl.exe -OutFile grabpl.exe image: grafana/ci-wix:0.1.1 name: initialize @@ -1393,6 +1395,8 @@ steps: environment: GCP_KEY: from_secret: gcp_key + GITHUB_TOKEN: + from_secret: github_token PRERELEASE_BUCKET: from_secret: prerelease_bucket image: grafana/ci-wix:0.1.1 @@ -1446,7 +1450,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.4/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.5/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -1467,7 +1471,8 @@ steps: - mv bin/grabpl /tmp/ - rmdir bin - mv grafana-enterprise /tmp/ - - /tmp/grabpl init-enterprise /tmp/grafana-enterprise ${DRONE_TAG} + - /tmp/grabpl init-enterprise --github-token $${GITHUB_TOKEN} /tmp/grafana-enterprise + ${DRONE_TAG} - mv /tmp/grafana-enterprise/deployment_tools_config.json deployment_tools_config.json - mkdir bin - mv /tmp/grabpl bin/ @@ -1477,6 +1482,9 @@ steps: - yarn install --immutable depends_on: - clone-enterprise + environment: + GITHUB_TOKEN: + from_secret: github_token image: grafana/build-container:1.4.8 name: initialize - commands: @@ -1896,7 +1904,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.4/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.5/windows/grabpl.exe -OutFile grabpl.exe - git clone "https://$$env:GITHUB_TOKEN@github.com/grafana/grafana-enterprise.git" - cd grafana-enterprise @@ -1911,10 +1919,13 @@ steps: - rm -r -force grafana-enterprise - cp grabpl.exe C:\App\grabpl.exe - rm -force grabpl.exe - - C:\App\grabpl.exe init-enterprise C:\App\grafana-enterprise + - C:\App\grabpl.exe init-enterprise --github-token $$env:GITHUB_TOKEN C:\App\grafana-enterprise - cp C:\App\grabpl.exe grabpl.exe depends_on: - clone + environment: + GITHUB_TOKEN: + from_secret: github_token image: grafana/ci-wix:0.1.1 name: initialize - commands: @@ -1934,6 +1945,8 @@ steps: environment: GCP_KEY: from_secret: gcp_key + GITHUB_TOKEN: + from_secret: github_token PRERELEASE_BUCKET: from_secret: prerelease_bucket image: grafana/ci-wix:0.1.1 @@ -1952,37 +1965,6 @@ volumes: path: /var/run/docker.sock name: docker --- -depends_on: -- oss-build-release -- oss-windows-release -- enterprise-build-release -- enterprise-windows-release -kind: pipeline -name: notify-release -platform: - arch: amd64 - os: linux -steps: -- image: plugins/slack - name: slack - settings: - channel: grafana-ci-notifications - template: |- - Build {{build.number}} failed for commit: : {{build.link}} - Branch: - Author: {{build.author}} - webhook: - from_secret: slack_webhook -trigger: - ref: - - refs/tags/v* - repo: - exclude: - - grafana/grafana - status: - - failure -type: docker ---- depends_on: [] kind: pipeline name: oss-build-test-release @@ -2008,7 +1990,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.4/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.5/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2359,7 +2341,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.4/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.5/windows/grabpl.exe -OutFile grabpl.exe image: grafana/ci-wix:0.1.1 name: initialize @@ -2381,6 +2363,8 @@ steps: environment: GCP_KEY: from_secret: gcp_key + GITHUB_TOKEN: + from_secret: github_token PRERELEASE_BUCKET: from_secret: prerelease_bucket image: grafana/ci-wix:0.1.1 @@ -2431,7 +2415,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.4/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.5/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -2452,7 +2436,7 @@ steps: - mv bin/grabpl /tmp/ - rmdir bin - mv grafana-enterprise /tmp/ - - /tmp/grabpl init-enterprise /tmp/grafana-enterprise + - /tmp/grabpl init-enterprise --github-token $${GITHUB_TOKEN} /tmp/grafana-enterprise - mv /tmp/grafana-enterprise/deployment_tools_config.json deployment_tools_config.json - mkdir bin - mv /tmp/grabpl bin/ @@ -2462,6 +2446,9 @@ steps: - yarn install --immutable depends_on: - clone-enterprise + environment: + GITHUB_TOKEN: + from_secret: github_token image: grafana/build-container:1.4.8 name: initialize - commands: @@ -2878,7 +2865,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.4/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.5/windows/grabpl.exe -OutFile grabpl.exe - git clone "https://$$env:GITHUB_TOKEN@github.com/grafana/grafana-enterprise.git" - cd grafana-enterprise @@ -2893,10 +2880,13 @@ steps: - rm -r -force grafana-enterprise - cp grabpl.exe C:\App\grabpl.exe - rm -force grabpl.exe - - C:\App\grabpl.exe init-enterprise C:\App\grafana-enterprise + - C:\App\grabpl.exe init-enterprise --github-token $$env:GITHUB_TOKEN C:\App\grafana-enterprise - cp C:\App\grabpl.exe grabpl.exe depends_on: - clone + environment: + GITHUB_TOKEN: + from_secret: github_token image: grafana/ci-wix:0.1.1 name: initialize - commands: @@ -2917,6 +2907,8 @@ steps: environment: GCP_KEY: from_secret: gcp_key + GITHUB_TOKEN: + from_secret: github_token PRERELEASE_BUCKET: from_secret: prerelease_bucket image: grafana/ci-wix:0.1.1 @@ -2948,7 +2940,7 @@ services: [] steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.4/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.5/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3068,7 +3060,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.4/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.5/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3401,7 +3393,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.4/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.5/windows/grabpl.exe -OutFile grabpl.exe image: grafana/ci-wix:0.1.1 name: initialize @@ -3418,6 +3410,8 @@ steps: environment: GCP_KEY: from_secret: gcp_key + GITHUB_TOKEN: + from_secret: github_token PRERELEASE_BUCKET: from_secret: prerelease_bucket image: grafana/ci-wix:0.1.1 @@ -3468,7 +3462,7 @@ services: steps: - commands: - mkdir -p bin - - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.4/grabpl + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.5/grabpl - chmod +x bin/grabpl image: byrnedo/alpine-curl:0.1.8 name: grabpl @@ -3489,7 +3483,7 @@ steps: - mv bin/grabpl /tmp/ - rmdir bin - mv grafana-enterprise /tmp/ - - /tmp/grabpl init-enterprise /tmp/grafana-enterprise + - /tmp/grabpl init-enterprise --github-token $${GITHUB_TOKEN} /tmp/grafana-enterprise - mv /tmp/grafana-enterprise/deployment_tools_config.json deployment_tools_config.json - mkdir bin - mv /tmp/grabpl bin/ @@ -3498,6 +3492,9 @@ steps: - yarn install --immutable depends_on: - clone-enterprise + environment: + GITHUB_TOKEN: + from_secret: github_token image: grafana/build-container:1.4.8 name: initialize - commands: @@ -3919,7 +3916,7 @@ steps: name: identify-runner - commands: - $$ProgressPreference = "SilentlyContinue" - - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.4/windows/grabpl.exe + - Invoke-WebRequest https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.7.5/windows/grabpl.exe -OutFile grabpl.exe - git clone "https://$$env:GITHUB_TOKEN@github.com/grafana/grafana-enterprise.git" - cd grafana-enterprise @@ -3934,10 +3931,13 @@ steps: - rm -r -force grafana-enterprise - cp grabpl.exe C:\App\grabpl.exe - rm -force grabpl.exe - - C:\App\grabpl.exe init-enterprise C:\App\grafana-enterprise + - C:\App\grabpl.exe init-enterprise --github-token $$env:GITHUB_TOKEN C:\App\grafana-enterprise - cp C:\App\grabpl.exe grabpl.exe depends_on: - clone + environment: + GITHUB_TOKEN: + from_secret: github_token image: grafana/ci-wix:0.1.1 name: initialize - commands: @@ -3953,6 +3953,8 @@ steps: environment: GCP_KEY: from_secret: gcp_key + GITHUB_TOKEN: + from_secret: github_token PRERELEASE_BUCKET: from_secret: prerelease_bucket image: grafana/ci-wix:0.1.1 @@ -3968,34 +3970,6 @@ volumes: path: /var/run/docker.sock name: docker --- -depends_on: -- oss-build-release-branch -- oss-windows-release-branch -- enterprise-build-release-branch -- enterprise-windows-release-branch -kind: pipeline -name: notify-release-branch -platform: - arch: amd64 - os: linux -steps: -- image: plugins/slack - name: slack - settings: - channel: grafana-ci-notifications - template: |- - Build {{build.number}} failed for commit: : {{build.link}} - Branch: - Author: {{build.author}} - webhook: - from_secret: slack_webhook -trigger: - ref: - - refs/heads/v[0-9]* - status: - - failure -type: docker ---- kind: pipeline name: scan-grafana/grafana:latest-image platform: @@ -4135,6 +4109,6 @@ kind: secret name: prerelease_bucket --- kind: signature -hmac: 6d40d34bf1be42d27e01854f4b5e6075be0d7739429e16d36dc4da85a2acb23f +hmac: b431c3bbdb4778dbed741bb5cd9840f106b4704280751dac4e145754f300a6ea ... diff --git a/scripts/drone/pipelines/release.star b/scripts/drone/pipelines/release.star index 0ade8480bf2..c271cc8bda3 100644 --- a/scripts/drone/pipelines/release.star +++ b/scripts/drone/pipelines/release.star @@ -267,10 +267,10 @@ def release_pipelines(ver_mode='release', trigger=None): depends_on=[p['name'] for p in oss_pipelines + enterprise_pipelines], ) - pipelines.append(notify_pipeline( - name='notify-{}'.format(ver_mode), slack_channel='grafana-ci-notifications', trigger=dict(trigger, status = ['failure']), - depends_on=[p['name'] for p in pipelines], template=failure_template, secret='slack_webhook', - )) + #pipelines.append(notify_pipeline( + # name='notify-{}'.format(ver_mode), slack_channel='grafana-ci-notifications', trigger=dict(trigger, status = ['failure']), + # depends_on=[p['name'] for p in pipelines], template=failure_template, secret='slack_webhook', + #)) return pipelines diff --git a/scripts/drone/steps/lib.star b/scripts/drone/steps/lib.star index 3644b3a466a..6ede295f3bf 100644 --- a/scripts/drone/steps/lib.star +++ b/scripts/drone/steps/lib.star @@ -1,6 +1,6 @@ load('scripts/drone/vault.star', 'from_secret', 'github_token', 'pull_secret', 'drone_token', 'prerelease_bucket') -grabpl_version = '2.7.4' +grabpl_version = '2.7.5' build_image = 'grafana/build-container:1.4.8' publish_image = 'grafana/grafana-ci-deploy:1.3.1' grafana_docker_image = 'grafana/drone-grafana-docker:0.3.2' @@ -84,11 +84,14 @@ def initialize_step(edition, platform, ver_mode, is_downstream=False, install_de 'depends_on': [ 'clone-enterprise', ], + 'environment': { + 'GITHUB_TOKEN': from_secret(github_token), + }, 'commands': [ 'mv bin/grabpl /tmp/', 'rmdir bin', 'mv grafana-enterprise /tmp/', - '/tmp/grabpl init-enterprise /tmp/grafana-enterprise{}'.format(source_commit), + '/tmp/grabpl init-enterprise --github-token $${{GITHUB_TOKEN}} /tmp/grafana-enterprise{}'.format(source_commit), 'mv /tmp/grafana-enterprise/deployment_tools_config.json deployment_tools_config.json', 'mkdir bin', 'mv /tmp/grabpl bin/' @@ -1072,7 +1075,8 @@ def get_windows_steps(edition, ver_mode, is_downstream=False): 'image': wix_image, 'environment': { 'GCP_KEY': from_secret('gcp_key'), - 'PRERELEASE_BUCKET': from_secret(prerelease_bucket) + 'PRERELEASE_BUCKET': from_secret(prerelease_bucket), + 'GITHUB_TOKEN': from_secret('github_token') }, 'commands': installer_commands, 'depends_on': [ @@ -1120,9 +1124,13 @@ def get_windows_steps(edition, ver_mode, is_downstream=False): 'rm -r -force grafana-enterprise', 'cp grabpl.exe C:\\App\\grabpl.exe', 'rm -force grabpl.exe', - 'C:\\App\\grabpl.exe init-enterprise C:\\App\\grafana-enterprise{}'.format(source_commit), + 'C:\\App\\grabpl.exe init-enterprise --github-token $$env:GITHUB_TOKEN C:\\App\\grafana-enterprise{}'.format(source_commit), 'cp C:\\App\\grabpl.exe grabpl.exe', ]) + if 'environment' in steps[1]: + steps[1]['environment'] + {'GITHUB_TOKEN': from_secret(github_token)} + else: + steps[1]['environment'] = {'GITHUB_TOKEN': from_secret(github_token)} return steps