JetBrains / teamcity-pipelines-dsl

Experimental Kotlin DSL library for TeamCity pipelines
Apache License 2.0
40 stars 20 forks source link

Artifact dependency points to non existing build configuration #5

Closed Logerfo closed 5 years ago

Logerfo commented 5 years ago

Code

project {
   sequence {
      parallel {
         sequence {
            build(Restore) {
               produces("**/*")
            }
            build(Build) {
               requires(Restore, "**/*")
            }
         }
         sequence {
            //...
         }
      }
   }
}

object Restore : BuildType({
   name = "Restore"
   steps {
      msBuild {
         //...
      }
   }
})

object Build : BuildType({
   name = "Build"
   steps {
      msBuild {
         //...
      }
   }
})

Error

Artifact dependency points to non existing build configuration with external id: _Restore

It actually prints twice in a row, I don't know why.

Solution attemps

I tried changing the build id:

object Restore : BuildType({
   id = "<PROJECT_ID>"
   name = "Restore"
})

But the error changed to:

Artifact dependency points to non existing build configuration with external id: __Restore

antonarhipov commented 5 years ago

@Logerfo do you have a full source of this configuration somewhere? Which TeamCity version do you use? I couldn't reproduce it with this code sample on 2019.1.x

Logerfo commented 5 years ago

I don't, it's a private project. I can try to reproduce it to a minimum configuration... I'm currently using TeamCity Professional 2019.1.2 (build 66342).

antonarhipov commented 5 years ago

OK, good, we are on the same TeamCity version. Please, if you can reproduce the issue with the minimal configuration that would help a lot.

Logerfo commented 5 years ago

Check out https://github.com/Logerfo/pipeline-test

Logerfo commented 5 years ago

I'm not sure if the build is actually supposed to pass successfully, but either way it should not fail so shortly. The following error must not be thrown:

Artifact dependency points to non existing build configuration with external id: PipelineTest_Restore

antonarhipov commented 5 years ago

Looks exactly like the code that I have created for testing: https://github.com/antonarhipov/myproject

Couldn't reproduce with your example neither.

Maybe teamcity-server.log reveals anything?

Logerfo commented 5 years ago

Here's what happened:

I don't think this has anything to do with the log verbosity, but perhaps this is happening in my private project because it's triggered by a github pull request and both base and target branches are NOT master. My master settings has only one build with a lot of steps. What I'm trying to do is make some steps parallel in order to make the build faster. Do you think that would be possible without messing with master?

antonarhipov commented 5 years ago

Ok, I probably understand now why it fails. So you have a master and a branch. And the configuration that fails is the one that you have in branch?

Unfortunately, I think there's no easy way for you to avoid touching the master. The build chain structure is taken from master. So if your master has one build configuration and you want to have two configurations in the branch - it is not going to work. You can read about branch specific settings and the limitations in this blog post: https://blog.jetbrains.com/teamcity/2018/01/branch-specific-settings-in-teamcity/


Just to clarify about the configuration that you have created: surrounding sequence with "parallel" block doesn't make the build configurations that are declared in the nested sequence block to run in parallel. See,

project {
  sequence {
    parallel {
       sequence {
           build(A)
           build(B)
       }
    }
  }
}

In this example, parallel block does nothing. The builds A and B are sequential. What actually is produced here is a project with A & B build configurations where B depends on A.

However, this

project {
  sequence {
    parallel {
       sequence {
           build(A)
           build(B)
       }
       sequence {
           build(C)
           build(D)
       }
    }
  }
}

would produce 2 build chins, A->B and C->D.

Logerfo commented 5 years ago

Yes, thanks, I'm aware of that. I have more than 10 steps, but restoring packages and building cannot be parallel. I just used the problematic part to reproduce the error. Alright then, I'll try to do this again when I manage to have the time to stop master commits and dedicate exclusively to this. It's a shame that Teamcity has such limitations... Anyway, thank you very much!