Trying to create dynamic resources as input for same job name or different job name. I am trying for feature branches concept in the same repo


#1

I have a one repo and when created a new feature/ branch .It has to create a dynamic new resource in the same pipeline but as input for dynamic jobs names but when I am trying its overriding the Job name and resource name.Please seen the below code


groups:

  • name: master
    jobs:

    • MasterJob
  • name: Develop
    jobs:

    • DevelopmentJob
  • name: Feature
    jobs:

    • feature-job

resources:

  • name: getMasterRepo
    type: git
    source: &repo-source
    uri: https://github.com/xxxxxxx/concourse-demo
    branch: master
    username: xxxxxxxxx
    password: xxxxxxxx

  • name: getDevelopRepo
    type: git
    source:
    <<: *repo-source
    branch: develop

  • name: feature
    type: git
    source:
    <<: *repo-source
    branch: ((branch-version))

jobs:

  • name: MasterJob
    plan:

    • get: concourse-demo
      resource: getMasterRepo
      trigger: true
    • task: task-running
      file: concourse-demo/ci/task-run.yml
  • name: DevelopmentJob
    plan:

    • get: concourse-demo
      resource: getDevelopRepo
      trigger: true
    • task: task-running
      file: concourse-demo/ci/task-run.yml
  • name: feature-job
    plan:

    • get: concourse-demo
      resource: feature
      trigger: true
    • task: task-running
      file: concourse-demo/ci/task-run.yml

my shell-script file is:

#!/usr/bin/env bash

set -eu

DIR=( cd "( dirname “${BASH_SOURCE[0]}” )" && pwd )

export fly_target=${fly_target:-concourse}

echo “Concourse API target ${fly_target}”

echo “Tutorial $(basename $DIR)”

#git branch | grep * | cut -d ’ ’ -f2 > ./version1.yml

export branchName=$(git branch | grep * | cut -d ’ ’ -f2)

cat > ./version1.yml << EOF

branch-version: ${branchName}

EOF

pushd $DIR

fly -t ${fly_target} set-pipeline -c concourse-demo.yml -p concurse-demo --load-vars-from=version1.yml -n

fly -t ${fly_target} unpause-pipeline -p concurse-demo

fly -t {fly_target} trigger-job -j concurse-demo/{branchName}

fly -t {fly_target} watch -j concurse-demo/{branchName}

popd