diff --git a/lib/interface/cli/commands/hybrid/helper.js b/lib/interface/cli/commands/hybrid/helper.js index 3becdc9ca..debf1a3f6 100644 --- a/lib/interface/cli/commands/hybrid/helper.js +++ b/lib/interface/cli/commands/hybrid/helper.js @@ -51,6 +51,13 @@ const RUNTIME_IMAGES = { PIPELINE_DEBUGGER_IMAGE: 'codefresh/cf-debugger:1.1.2', }; +const DEMO_STEP_IMAGE = { + 'docker.io': 'alpine:latest', + 'quay.io': 'quay.io/codefresh/alpine:3.11', + 'gcr.io': 'gcr.io/google-containers/alpine-with-bash', + default: 'quay.io/codefresh/alpine:3.11' +} + const maxRuntimeNameLength = 63; const DefaultLogFormatter = 'plain'; @@ -86,7 +93,7 @@ async function getTestPipelineLink(pipelineName, pipeline) { return ''; } -async function createTestPipeline(runtimeName, pipelineName, pipelineCommands) { +async function createTestPipeline(runtimeName, pipelineName, pipelineCommands, dockerRegistry) { await _createRunnerProjectIfNotExists(); console.log(`Creating test pipeline with the name: "${colors.cyan(pipelineName)}" ` + `in project "${colors.cyan(INSTALLATION_DEFAULTS.PROJECT_NAME)}"`); @@ -95,12 +102,15 @@ async function createTestPipeline(runtimeName, pipelineName, pipelineCommands) { pipeline.spec.runtimeEnvironment = { name: runtimeName, }; + + const demoStepImage = DEMO_STEP_IMAGE[dockerRegistry] || DEMO_STEP_IMAGE.default; + pipeline.spec.steps = {}; pipeline.spec.stages = ['test']; pipeline.spec.steps.test = { stage: 'test', title: 'test', - image: 'alpine:latest', + image: demoStepImage, commands: pipelineCommands || ['echo hello Codefresh Runner!'], }; @@ -130,11 +140,10 @@ async function getTestPipeline(pipelineName) { return pipeline; } - return null; } -async function updateTestPipelineRuntime(pipeline, runtimeName, pipelineName) { +async function updateTestPipelineRuntime(pipeline, runtimeName, pipelineName, dockerRegistry) { let _pipeline = pipeline; if (!_pipeline) { const testPipeline = await getTestPipeline(pipelineName); @@ -147,6 +156,10 @@ async function updateTestPipelineRuntime(pipeline, runtimeName, pipelineName) { name: runtimeName, }; + let demoStepImage = DEMO_STEP_IMAGE[dockerRegistry] || DEMO_STEP_IMAGE.default; + + _pipeline.spec.steps.test.image = demoStepImage; + await sdk.pipelines.replace( { name: _pipeline.metadata.name }, { diff --git a/lib/interface/cli/commands/hybrid/init.cmd.js b/lib/interface/cli/commands/hybrid/init.cmd.js index b9291a867..9a04c85b1 100644 --- a/lib/interface/cli/commands/hybrid/init.cmd.js +++ b/lib/interface/cli/commands/hybrid/init.cmd.js @@ -843,18 +843,20 @@ const initCmd = new Command({ installationPlan.getContext('runtimeName'), INSTALLATION_DEFAULTS.DEMO_PIPELINE_NAME, ['echo hello Codefresh Runner!'], + dockerRegistry ); }, installationEvent: installationProgress.events.PIPELINE_CREATED, }); } else { - installationPlan.addStep({ + installationPlan.addStep({ name: 'update test pipeline runtime', func: async () => { - await updateTestPipelineRuntime( + await updateTestPipelineRuntime( undefined, installationPlan.getContext('runtimeName'), INSTALLATION_DEFAULTS.DEMO_PIPELINE_NAME, + dockerRegistry ); }, errMessage: colors.yellow('*warning* could not update test pipeline runtime, you can' + diff --git a/package.json b/package.json index 71049c8b9..16bbf46e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codefresh", - "version": "0.75.10", + "version": "0.75.11", "description": "Codefresh command line utility", "main": "index.js", "preferGlobal": true,