diff options
Diffstat (limited to 'app/assets/javascripts/ci/runner')
17 files changed, 295 insertions, 16 deletions
diff --git a/app/assets/javascripts/ci/runner/admin_register_runner/admin_register_runner_app.vue b/app/assets/javascripts/ci/runner/admin_register_runner/admin_register_runner_app.vue index b291be41203..1ae119da959 100644 --- a/app/assets/javascripts/ci/runner/admin_register_runner/admin_register_runner_app.vue +++ b/app/assets/javascripts/ci/runner/admin_register_runner/admin_register_runner_app.vue @@ -2,12 +2,13 @@ import { GlButton } from '@gitlab/ui'; import { s__, sprintf } from '~/locale'; import { createAlert } from '~/flash'; -import { getParameterByName } from '~/lib/utils/url_utility'; +import { getParameterByName, updateHistory, mergeUrlParams } from '~/lib/utils/url_utility'; import { convertToGraphQLId } from '~/graphql_shared/utils'; import { TYPENAME_CI_RUNNER } from '~/graphql_shared/constants'; import runnerForRegistrationQuery from '../graphql/register/runner_for_registration.query.graphql'; import { I18N_FETCH_ERROR, PARAM_KEY_PLATFORM, DEFAULT_PLATFORM } from '../constants'; import RegistrationInstructions from '../components/registration/registration_instructions.vue'; +import PlatformsDrawer from '../components/registration/platforms_drawer.vue'; import { captureException } from '../sentry_utils'; export default { @@ -15,6 +16,7 @@ export default { components: { GlButton, RegistrationInstructions, + PlatformsDrawer, }, props: { runnerId: { @@ -30,6 +32,7 @@ export default { return { platform: getParameterByName(PARAM_KEY_PLATFORM) || DEFAULT_PLATFORM, runner: null, + isDrawerOpen: false, }; }, apollo: { @@ -62,6 +65,21 @@ export default { return this.runner?.ephemeralAuthenticationToken; }, }, + watch: { + platform(platform) { + updateHistory({ + url: mergeUrlParams({ [PARAM_KEY_PLATFORM]: platform }, window.location.href), + }); + }, + }, + methods: { + onSelectPlatform(platform) { + this.platform = platform; + }, + onToggleDrawer(val = !this.isDrawerOpen) { + this.isDrawerOpen = val; + }, + }, }; </script> <template> @@ -72,6 +90,14 @@ export default { :loading="$apollo.queries.runner.loading" :platform="platform" :token="ephemeralAuthenticationToken" + @toggleDrawer="onToggleDrawer" + /> + + <platforms-drawer + :platform="platform" + :open="isDrawerOpen" + @selectPlatform="onSelectPlatform" + @close="onToggleDrawer(false)" /> <gl-button :href="runnersPath" variant="confirm">{{ diff --git a/app/assets/javascripts/ci/runner/components/registration/platforms_drawer.vue b/app/assets/javascripts/ci/runner/components/registration/platforms_drawer.vue new file mode 100644 index 00000000000..a56302898ca --- /dev/null +++ b/app/assets/javascripts/ci/runner/components/registration/platforms_drawer.vue @@ -0,0 +1,131 @@ +<script> +import { GlDrawer, GlFormGroup, GlFormSelect, GlLink, GlSprintf } from '@gitlab/ui'; +import { getContentWrapperHeight } from '~/lib/utils/dom_utils'; +import { DRAWER_Z_INDEX } from '~/lib/utils/constants'; + +import { + DEFAULT_PLATFORM, + MACOS_PLATFORM, + LINUX_PLATFORM, + WINDOWS_PLATFORM, + INSTALL_HELP_URL, +} from '../../constants'; +import { installScript, platformArchitectures } from './utils'; + +import CliCommand from './cli_command.vue'; + +export default { + components: { + GlDrawer, + GlFormGroup, + GlFormSelect, + GlLink, + GlSprintf, + CliCommand, + }, + props: { + open: { + type: Boolean, + required: true, + }, + platform: { + type: String, + required: false, + default: DEFAULT_PLATFORM, + }, + }, + data() { + return { + selectedPlatform: this.platform, + selectedArchitecture: null, + }; + }, + computed: { + drawerHeightOffset() { + return getContentWrapperHeight('.content-wrapper'); + }, + architectureOptions() { + return platformArchitectures({ platform: this.selectedPlatform }); + }, + script() { + return installScript({ + platform: this.selectedPlatform, + architecture: this.selectedArchitecture, + }); + }, + }, + watch: { + selectedPlatform() { + this.selectedArchitecture = + this.architectureOptions.find((value) => value === this.selectedArchitecture) || + this.architectureOptions[0]; + + this.$emit('selectPlatform', this.selectedPlatform); + }, + }, + created() { + [this.selectedArchitecture] = this.architectureOptions; + }, + methods: { + onClose() { + this.$emit('close'); + }, + }, + platformOptions: [ + /* eslint-disable @gitlab/require-i18n-strings */ + { value: LINUX_PLATFORM, text: 'Linux' }, + { value: MACOS_PLATFORM, text: 'macOS' }, + { value: WINDOWS_PLATFORM, text: 'Windows' }, + /* eslint-enable @gitlab/require-i18n-strings */ + ], + INSTALL_HELP_URL, + DRAWER_Z_INDEX, +}; +</script> +<template> + <gl-drawer + :open="open" + :header-height="drawerHeightOffset" + :z-index="$options.DRAWER_Z_INDEX" + @close="onClose" + > + <template #title> + <h2 class="gl-my-0 gl-font-size-h2 gl-line-height-24"> + {{ s__('Runners|Install GitLab Runner') }} + </h2> + </template> + <div> + <p>{{ s__('Runners|Select platform specifications to install GitLab Runner.') }}</p> + + <gl-form-group :label="s__('Runners|Environment')" label-for="runner-environment-select"> + <gl-form-select + id="runner-environment-select" + v-model="selectedPlatform" + :options="$options.platformOptions" + /> + </gl-form-group> + + <gl-form-group :label="s__('Runners|Architecture')" label-for="runner-architecture-select"> + <gl-form-select + id="runner-architecture-select" + v-model="selectedArchitecture" + :options="architectureOptions" + /> + </gl-form-group> + + <cli-command :command="script" /> + + <p> + <gl-sprintf + :message=" + s__('Runners|See more %{linkStart}installation methods and architectures%{linkEnd}.') + " + > + <template #link="{ content }"> + <gl-link :href="$options.INSTALL_HELP_URL">{{ content }}</gl-link> + </template> + </gl-sprintf> + </p> + </div> + </gl-drawer> +</template> diff --git a/app/assets/javascripts/ci/runner/components/registration/registration_instructions.vue b/app/assets/javascripts/ci/runner/components/registration/registration_instructions.vue index e01d8b64839..e611cae1f35 100644 --- a/app/assets/javascripts/ci/runner/components/registration/registration_instructions.vue +++ b/app/assets/javascripts/ci/runner/components/registration/registration_instructions.vue @@ -2,7 +2,7 @@ import { GlIcon, GlLink, GlSprintf, GlSkeletonLoader } from '@gitlab/ui'; import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; -import { INSTALL_HELP_URL, EXECUTORS_HELP_URL, SERVICE_COMMANDS_HELP_URL } from '../../constants'; +import { EXECUTORS_HELP_URL, SERVICE_COMMANDS_HELP_URL } from '../../constants'; import CliCommand from './cli_command.vue'; import { commandPrompt, registerCommand, runCommand } from './utils'; @@ -42,7 +42,11 @@ export default { return runCommand({ platform: this.platform }); }, }, - INSTALL_HELP_URL, + methods: { + toggleDrawer(val) { + this.$emit('toggleDrawer', val); + }, + }, EXECUTORS_HELP_URL, SERVICE_COMMANDS_HELP_URL, }; @@ -58,7 +62,7 @@ export default { " > <template #link="{ content }"> - <gl-link :href="$options.INSTALL_HELP_URL">{{ content }}</gl-link> + <gl-link @click="toggleDrawer()">{{ content }}</gl-link> </template> </gl-sprintf> </p> diff --git a/app/assets/javascripts/ci/runner/components/registration/registration_token_reset_dropdown_item.vue b/app/assets/javascripts/ci/runner/components/registration/registration_token_reset_dropdown_item.vue index ac2793654c8..db8c953ce3c 100644 --- a/app/assets/javascripts/ci/runner/components/registration/registration_token_reset_dropdown_item.vue +++ b/app/assets/javascripts/ci/runner/components/registration/registration_token_reset_dropdown_item.vue @@ -1,6 +1,6 @@ <script> import { GlDropdownItem, GlLoadingIcon, GlModal, GlModalDirective } from '@gitlab/ui'; -import { createAlert } from '~/flash'; +import { createAlert } from '~/alert'; import { TYPENAME_GROUP, TYPENAME_PROJECT } from '~/graphql_shared/constants'; import { convertToGraphQLId } from '~/graphql_shared/utils'; import { __, s__ } from '~/locale'; diff --git a/app/assets/javascripts/ci/runner/components/registration/scripts/linux/install.sh b/app/assets/javascripts/ci/runner/components/registration/scripts/linux/install.sh new file mode 100644 index 00000000000..a8ba2592128 --- /dev/null +++ b/app/assets/javascripts/ci/runner/components/registration/scripts/linux/install.sh @@ -0,0 +1,12 @@ +# Download the binary for your system +sudo curl -L --output /usr/local/bin/gitlab-runner ${GITLAB_CI_RUNNER_DOWNLOAD_LOCATION} + +# Give it permission to execute +sudo chmod +x /usr/local/bin/gitlab-runner + +# Create a GitLab Runner user +sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash + +# Install and run as a service +sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner +sudo gitlab-runner start diff --git a/app/assets/javascripts/ci/runner/components/registration/scripts/osx/install.sh b/app/assets/javascripts/ci/runner/components/registration/scripts/osx/install.sh new file mode 100644 index 00000000000..76c893bacfc --- /dev/null +++ b/app/assets/javascripts/ci/runner/components/registration/scripts/osx/install.sh @@ -0,0 +1,11 @@ +# Download the binary for your system +sudo curl --output /usr/local/bin/gitlab-runner ${GITLAB_CI_RUNNER_DOWNLOAD_LOCATION} + +# Give it permission to execute +sudo chmod +x /usr/local/bin/gitlab-runner + +# The rest of the commands execute as the user who will run the runner +# Register the runner (steps below), then run +cd ~ +gitlab-runner install +gitlab-runner start diff --git a/app/assets/javascripts/ci/runner/components/registration/scripts/windows/install.ps1 b/app/assets/javascripts/ci/runner/components/registration/scripts/windows/install.ps1 new file mode 100644 index 00000000000..019363fc3f7 --- /dev/null +++ b/app/assets/javascripts/ci/runner/components/registration/scripts/windows/install.ps1 @@ -0,0 +1,13 @@ +# Run PowerShell: https://docs.microsoft.com/en-us/powershell/scripting/windows-powershell/starting-windows-powershell?view=powershell-7#with-administrative-privileges-run-as-administrator +# Create a folder somewhere on your system, for example: C:\GitLab-Runner +New-Item -Path 'C:\GitLab-Runner' -ItemType Directory + +# Change to the folder +cd 'C:\GitLab-Runner' + +# Download binary +Invoke-WebRequest -Uri "${GITLAB_CI_RUNNER_DOWNLOAD_LOCATION}" -OutFile "gitlab-runner.exe" + +# Register the runner (steps below), then run +.\gitlab-runner.exe install +.\gitlab-runner.exe start diff --git a/app/assets/javascripts/ci/runner/components/registration/utils.js b/app/assets/javascripts/ci/runner/components/registration/utils.js index 32fb8eac5e9..621963349ae 100644 --- a/app/assets/javascripts/ci/runner/components/registration/utils.js +++ b/app/assets/javascripts/ci/runner/components/registration/utils.js @@ -1,11 +1,15 @@ +/* eslint-disable @gitlab/require-i18n-strings */ import { DEFAULT_PLATFORM, LINUX_PLATFORM, MACOS_PLATFORM, WINDOWS_PLATFORM, + DOWNLOAD_LOCATIONS, } from '../../constants'; +import linuxInstall from './scripts/linux/install.sh?raw'; +import osxInstall from './scripts/osx/install.sh?raw'; +import windowsInstall from './scripts/windows/install.ps1?raw'; -/* eslint-disable @gitlab/require-i18n-strings */ const OS = { [LINUX_PLATFORM]: { commandPrompt: '$', @@ -33,11 +37,40 @@ export const registerCommand = ({ platform, url = gon.gitlab_url, registrationTo return [ `${executable({ platform })} register`, ` --url ${url}`, - ` --registration-token ${registrationToken}`, + ...(registrationToken ? [` --registration-token ${registrationToken}`] : []), ]; }; export const runCommand = ({ platform }) => { return `${executable({ platform })} run`; }; -/* eslint-enable @gitlab/require-i18n-strings */ + +const importInstallScript = ({ platform = DEFAULT_PLATFORM }) => { + switch (platform) { + case LINUX_PLATFORM: + return linuxInstall; + case MACOS_PLATFORM: + return osxInstall; + case WINDOWS_PLATFORM: + return windowsInstall; + default: + return ''; + } +}; + +export const platformArchitectures = ({ platform }) => { + return DOWNLOAD_LOCATIONS[platform].map(({ arch }) => arch); +}; + +export const installScript = ({ platform, architecture }) => { + const downloadLocation = DOWNLOAD_LOCATIONS[platform].find(({ arch }) => arch === architecture) + .url; + + return importInstallScript({ platform }) + .replace( + // eslint-disable-next-line no-template-curly-in-string + '${GITLAB_CI_RUNNER_DOWNLOAD_LOCATION}', + downloadLocation, + ) + .trim(); +}; diff --git a/app/assets/javascripts/ci/runner/components/runner_bulk_delete.vue b/app/assets/javascripts/ci/runner/components/runner_bulk_delete.vue index 8dde3ac4e19..e7b26ec6d4e 100644 --- a/app/assets/javascripts/ci/runner/components/runner_bulk_delete.vue +++ b/app/assets/javascripts/ci/runner/components/runner_bulk_delete.vue @@ -1,6 +1,6 @@ <script> import { GlButton, GlModalDirective, GlModal, GlSprintf } from '@gitlab/ui'; -import { createAlert } from '~/flash'; +import { createAlert } from '~/alert'; import { __, s__, n__, sprintf } from '~/locale'; import checkedRunnerIdsQuery from '../graphql/list/checked_runner_ids.query.graphql'; import BulkRunnerDelete from '../graphql/list/bulk_runner_delete.mutation.graphql'; diff --git a/app/assets/javascripts/ci/runner/components/runner_delete_button.vue b/app/assets/javascripts/ci/runner/components/runner_delete_button.vue index f02e6bce5c3..020487fc727 100644 --- a/app/assets/javascripts/ci/runner/components/runner_delete_button.vue +++ b/app/assets/javascripts/ci/runner/components/runner_delete_button.vue @@ -1,7 +1,7 @@ <script> import { GlButton, GlModalDirective, GlTooltipDirective } from '@gitlab/ui'; import runnerDeleteMutation from '~/ci/runner/graphql/shared/runner_delete.mutation.graphql'; -import { createAlert } from '~/flash'; +import { createAlert } from '~/alert'; import { sprintf, s__ } from '~/locale'; import { captureException } from '~/ci/runner/sentry_utils'; import { getIdFromGraphQLId } from '~/graphql_shared/utils'; diff --git a/app/assets/javascripts/ci/runner/components/runner_jobs.vue b/app/assets/javascripts/ci/runner/components/runner_jobs.vue index 9003eba3636..f5287f597ab 100644 --- a/app/assets/javascripts/ci/runner/components/runner_jobs.vue +++ b/app/assets/javascripts/ci/runner/components/runner_jobs.vue @@ -1,6 +1,6 @@ <script> import { GlSkeletonLoader } from '@gitlab/ui'; -import { createAlert } from '~/flash'; +import { createAlert } from '~/alert'; import runnerJobsQuery from '../graphql/show/runner_jobs.query.graphql'; import { I18N_FETCH_ERROR, I18N_NO_JOBS_FOUND, RUNNER_DETAILS_JOBS_PAGE_SIZE } from '../constants'; import { captureException } from '../sentry_utils'; diff --git a/app/assets/javascripts/ci/runner/components/runner_pause_button.vue b/app/assets/javascripts/ci/runner/components/runner_pause_button.vue index 2c80518e772..a27af232e97 100644 --- a/app/assets/javascripts/ci/runner/components/runner_pause_button.vue +++ b/app/assets/javascripts/ci/runner/components/runner_pause_button.vue @@ -1,7 +1,7 @@ <script> import { GlButton, GlTooltipDirective } from '@gitlab/ui'; import runnerToggleActiveMutation from '~/ci/runner/graphql/shared/runner_toggle_active.mutation.graphql'; -import { createAlert } from '~/flash'; +import { createAlert } from '~/alert'; import { captureException } from '~/ci/runner/sentry_utils'; import { I18N_PAUSE, I18N_PAUSE_TOOLTIP, I18N_RESUME, I18N_RESUME_TOOLTIP } from '../constants'; diff --git a/app/assets/javascripts/ci/runner/components/runner_projects.vue b/app/assets/javascripts/ci/runner/components/runner_projects.vue index 4a6e90b44a9..4cfc57340f5 100644 --- a/app/assets/javascripts/ci/runner/components/runner_projects.vue +++ b/app/assets/javascripts/ci/runner/components/runner_projects.vue @@ -1,7 +1,7 @@ <script> import { GlSearchBoxByType, GlSkeletonLoader } from '@gitlab/ui'; import { sprintf, formatNumber } from '~/locale'; -import { createAlert } from '~/flash'; +import { createAlert } from '~/alert'; import runnerProjectsQuery from '../graphql/show/runner_projects.query.graphql'; import { I18N_ASSIGNED_PROJECTS, diff --git a/app/assets/javascripts/ci/runner/components/runner_update_form.vue b/app/assets/javascripts/ci/runner/components/runner_update_form.vue index a9790d06ca7..dd8e965cecd 100644 --- a/app/assets/javascripts/ci/runner/components/runner_update_form.vue +++ b/app/assets/javascripts/ci/runner/components/runner_update_form.vue @@ -13,7 +13,7 @@ import { modelToUpdateMutationVariables, runnerToModel, } from 'ee_else_ce/ci/runner/runner_update_form_utils'; -import { createAlert, VARIANT_SUCCESS } from '~/flash'; +import { createAlert, VARIANT_SUCCESS } from '~/alert'; import { redirectTo } from '~/lib/utils/url_utility'; import { __ } from '~/locale'; import { captureException } from '~/ci/runner/sentry_utils'; diff --git a/app/assets/javascripts/ci/runner/components/search_tokens/tag_token.vue b/app/assets/javascripts/ci/runner/components/search_tokens/tag_token.vue index 6e7c41885f8..1de7775090a 100644 --- a/app/assets/javascripts/ci/runner/components/search_tokens/tag_token.vue +++ b/app/assets/javascripts/ci/runner/components/search_tokens/tag_token.vue @@ -1,6 +1,6 @@ <script> import { GlFilteredSearchSuggestion, GlToken } from '@gitlab/ui'; -import { createAlert } from '~/flash'; +import { createAlert } from '~/alert'; import axios from '~/lib/utils/axios_utils'; import { s__ } from '~/locale'; diff --git a/app/assets/javascripts/ci/runner/constants.js b/app/assets/javascripts/ci/runner/constants.js index 054e6b954d0..8e31b7f2d44 100644 --- a/app/assets/javascripts/ci/runner/constants.js +++ b/app/assets/javascripts/ci/runner/constants.js @@ -183,6 +183,55 @@ export const MACOS_PLATFORM = 'osx'; export const WINDOWS_PLATFORM = 'windows'; export const AWS_PLATFORM = 'aws'; +export const DOWNLOAD_LOCATIONS = { + [LINUX_PLATFORM]: [ + { + arch: 'amd64', + url: + 'https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64', + }, + { + arch: '386', + url: + 'https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-386', + }, + { + arch: 'arm', + url: + 'https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-arm', + }, + { + arch: 'arm64', + url: + 'https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-arm64', + }, + ], + [MACOS_PLATFORM]: [ + { + arch: 'amd64', + url: + 'https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-darwin-amd64', + }, + { + arch: 'arm64', + url: + 'https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-darwin-arm64', + }, + ], + [WINDOWS_PLATFORM]: [ + { + arch: 'amd64', + url: + 'https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-windows-amd64.exe', + }, + { + arch: '386', + url: + 'https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-windows-386.exe', + }, + ], +}; + export const DEFAULT_PLATFORM = LINUX_PLATFORM; // Runner docs are in a separate repository and are not shipped with GitLab diff --git a/app/assets/javascripts/ci/runner/local_storage_alert/show_alert_from_local_storage.js b/app/assets/javascripts/ci/runner/local_storage_alert/show_alert_from_local_storage.js index d768a06494a..bad3ca6024e 100644 --- a/app/assets/javascripts/ci/runner/local_storage_alert/show_alert_from_local_storage.js +++ b/app/assets/javascripts/ci/runner/local_storage_alert/show_alert_from_local_storage.js @@ -7,7 +7,7 @@ export const showAlertFromLocalStorage = async () => { if (alertOptions) { try { - const { createAlert } = await import('~/flash'); + const { createAlert } = await import('~/alert'); createAlert(JSON.parse(alertOptions)); } catch { // ignore when the alert data cannot be parsed |