Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create pipeline from string #59

Open
kpurdon opened this issue Jul 23, 2021 · 2 comments
Open

Cannot create pipeline from string #59

kpurdon opened this issue Jul 23, 2021 · 2 comments

Comments

@kpurdon
Copy link

kpurdon commented Jul 23, 2021

It's unclear if this is possible or not, but the code/docs seems to indicate I should be able to do it. I'm generating code in terraform and yaml encoding it to pass to terraform.

resource "codefresh_pipeline" "schedule_all" {
  for_each = toset(["syndio/syndio", "syndio/ce"])

  name = "${codefresh_project.syndio_codefresh_project.name}/Schedule All (${each.key}) Pipelines"

  original_yaml_string = yamlencode({
    version = "1.0"
    stages  = ["deploy"]
    steps = {
      schedule_all_pipelines = {
        type  = "parallel"
        title = "Schedule All Pipelines"
        steps = { for p in local.pipelines : lower(replace("schedule_${p.name}", " ", "_")) => {
          title = "Schedule ${p.name}"
          stage = "deploy"
          type  = "codefresh-run"
          arguments = {
            PIPELINE_ID = "${codefresh_project.syndio_codefresh_project.name}/${p.name}"
            DETACH      = true
            BRANCH      = "$${{CF_BRANCH}}"
            SHA         = "$${{CF_REVISION}}"
            TRIGGER_ID  = each.key
          }
        } if p.repo == each.key }
      }
    }
  })

  spec {
    concurrency = 1
    pack_id     = local.machine_types["small"]

    trigger {
      name          = each.key
      description   = "Manual Branch Trigger"
      type          = "git"
      provider      = "github"
      repo          = each.key
      disabled      = true
      context       = "syndio"
      branch_regex  = "/.*/gi"
      comment_regex = "/.*/gi"
      events = [
        "push.heads"
      ]
    }
  }
}

this generates an API request which faills w/ the following error

module.syndio_codefresh.codefresh_pipeline.schedule_all["syndio/syndio"]: Creating...
module.syndio_codefresh.codefresh_pipeline.schedule_all["syndio/ce"]: Creating...

Error: 500 Internal Server Error, {"status":500,"code":"1001","name":"INTERNAL_SERVER_ERROR","message":"500 - {\"message\":\"Error: Can't get project; caused by Error: Can't get project\"}","context":{}}



Error: 500 Internal Server Error, {"status":500,"code":"1001","name":"INTERNAL_SERVER_ERROR","message":"500 - {\"message\":\"Error: Can't get project; caused by Error: Can't get project\"}","context":{}}

one of the api request bodies sent to codefresh is

Headers: 

{
  "correlationId": "7b00cd5a3f39c17a3b2a09ba94138efa, 7b00cd5a3f39c17a3b2a09ba94138efa"
}

Body: 

{
  "metadata": {
    "name": "Staging/Deploy All (syndio/ce)",
    "labels": {},
    "originalYamlString": "\"deploy_all_pipelines\":\n  \"steps\":\n    \"steps\":\n      \"schedule_payeq_deploy\":\n        \"arguments\":\n          \"BRANCH\": \"${{CF_BRANCH}}\"\n          \"DETACH\": true\n          \"PIPELINE_ID\": \"Staging/PayEQ Deploy\"\n          \"SHA\": \"${{CF_REVISION}}\"\n          \"TRIGGER_ID\": \"syndio/ce\"\n        \"stage\": \"deploy\"\n        \"title\": \"Schedule PayEQ Deploy\"\n        \"type\": \"codefresh-run\"\n  \"title\": \"Schedule All Pipelines\"\n  \"type\": \"parallel\"\n\"stages\":\n- \"deploy\"\n\"version\": \"1.0\"\n"
  },
  "spec": {
    "triggers": [
      {
        "name": "syndio/ce",
        "description": "Manual Branch Trigger",
        "type": "git",
        "repo": "syndio/ce",
        "events": [
          "push.heads"
        ],
        "branchRegex": "/.*/gi",
        "branchRegexInput": "regex",
        "commentRegex": "/.*/gi",
        "provider": "github",
        "disabled": true,
        "context": "syndio"
      }
    ],
    "concurrency": 1,
    "steps": {},
    "stages": [
      "deploy"
    ],
    "runtimeEnvironment": {},
    "hooks": {}
  }
}

This looks incorrect when compared to working requests from the codefresh cli. Since giving a spec directly (not repo sourced) doesn't seem to be exposed in any way other than giving the original_yaml_string and letting the provider handle it.

@kpurdon
Copy link
Author

kpurdon commented Jul 23, 2021

Of note I'm using an up to date fork of this provider since #44 is still not reviewed/merged.

@mattmelgard
Copy link

Hey @denis-codefresh, Any chance this might have already been fixed? This one has also been open for a while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants