{"action":"created","comment":{"url":"https://api.github.com/repos/alphagov/paas-cf/pulls/comments/56016329","id":56016329,"diff_hunk":"@@ -47,10 +47,48 @@ resources:\n       region_name: {{aws_region}}\n       versioned_file: cf-secrets.yml\n \n+  - name: concourse-manifest\n+    type: s3-iam\n+    source:\n+      bucket: {{state_bucket}}\n+      region_name: {{aws_region}}\n+      versioned_file: concourse-manifest.yml\n+\n jobs:\n   - name: init\n     serial: true\n     plan:\n+      - get: paas-cf\n+      - get: concourse-manifest\n+      - task: self-update-pipeline\n+        config:\n+          platform: linux\n+          image: docker:///governmentpaas/self-update-pipelines\n+          inputs:\n+            - name: paas-cf\n+            - name: concourse-manifest\n+          params:\n+            DEPLOY_ENV: {{deploy_env}}\n+            BRANCH: {{branch_name}}\n+            MAKEFILE_ENV_TARGET: {{makefile_env_target}}\n+            SELF_UPDATE_PIPELINE: {{self_update_pipeline}}\n+            PIPELINES_TO_UPDATE: {{pipeline_name}}\n+          run:\n+            path: bash\n+            args:\n+              - -e\n+              - -c\n+              - |\n+                if [ \"$SELF_UPDATE_PIPELINE\" != \"true\" ]; then\n+                  echo \"Self update pipeline is disabled (set SELF_UPDATE_PIPELINE=true to enable)\"\n+                else\n+                  echo \"Self update pipeline is enabled (set SELF_UPDATE_PIPELINE=false to disable)\"\n+\n+                  VAL_FROM_YAML=$(pwd)/paas-cf/concourse/scripts/val_from_yaml.rb\n+                  export CONCOURSE_ATC_PASSWORD=$($VAL_FROM_YAML jobs.concourse.properties.atc.basic_auth_password concourse-manifest/concourse-manifest.yml)\n+\n+                  make -C ./paas-cf ${MAKEFILE_ENV_TARGET}\n+                fi","path":"concourse/pipelines/destroy-cloudfoundry.yml","position":45,"original_position":45,"commit_id":"911896c17f66ac5108b3439efab1320de1f706c7","original_commit_id":"911896c17f66ac5108b3439efab1320de1f706c7","user":{"login":"dcarley","id":260438,"avatar_url":"https://avatars.githubusercontent.com/u/260438?v=3","gravatar_id":"","url":"https://api.github.com/users/dcarley","html_url":"https://github.com/dcarley","followers_url":"https://api.github.com/users/dcarley/followers","following_url":"https://api.github.com/users/dcarley/following{/other_user}","gists_url":"https://api.github.com/users/dcarley/gists{/gist_id}","starred_url":"https://api.github.com/users/dcarley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcarley/subscriptions","organizations_url":"https://api.github.com/users/dcarley/orgs","repos_url":"https://api.github.com/users/dcarley/repos","events_url":"https://api.github.com/users/dcarley/events{/privacy}","received_events_url":"https://api.github.com/users/dcarley/received_events","type":"User","site_admin":false},"body":"Can we move this to a script in `concourse/scripts/` to reduce duplication in each pipeline and make it easier to maintain? When we do, it should have `set -eu` at the top of it to abort on errors and unbound variables.","created_at":"2016-03-14T15:14:54Z","updated_at":"2016-03-14T15:14:54Z","html_url":"https://github.com/alphagov/paas-cf/pull/156#discussion_r56016329","pull_request_url":"https://api.github.com/repos/alphagov/paas-cf/pulls/156","_links":{"self":{"href":"https://api.github.com/repos/alphagov/paas-cf/pulls/comments/56016329"},"html":{"href":"https://github.com/alphagov/paas-cf/pull/156#discussion_r56016329"},"pull_request":{"href":"https://api.github.com/repos/alphagov/paas-cf/pulls/156"}}},"pull_request":{"url":"https://api.github.com/repos/alphagov/paas-cf/pulls/156","id":62746812,"html_url":"https://github.com/alphagov/paas-cf/pull/156","diff_url":"https://github.com/alphagov/paas-cf/pull/156.diff","patch_url":"https://github.com/alphagov/paas-cf/pull/156.patch","issue_url":"https://api.github.com/repos/alphagov/paas-cf/issues/156","number":156,"state":"open","locked":false,"title":"[#114000923] Implement self-update pipelines for microbosh and cloudfoundry","user":{"login":"keymon","id":280032,"avatar_url":"https://avatars.githubusercontent.com/u/280032?v=3","gravatar_id":"","url":"https://api.github.com/users/keymon","html_url":"https://github.com/keymon","followers_url":"https://api.github.com/users/keymon/followers","following_url":"https://api.github.com/users/keymon/following{/other_user}","gists_url":"https://api.github.com/users/keymon/gists{/gist_id}","starred_url":"https://api.github.com/users/keymon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keymon/subscriptions","organizations_url":"https://api.github.com/users/keymon/orgs","repos_url":"https://api.github.com/users/keymon/repos","events_url":"https://api.github.com/users/keymon/events{/privacy}","received_events_url":"https://api.github.com/users/keymon/received_events","type":"User","site_admin":false},"body":"[#114000923 elf-updating pipelines](https://www.pivotaltracker.com/story/show/114000923)\r\n\r\nWhat?\r\n-----\r\n\r\nIn order to ensure that we promote changes from paas-cf into environments in a consistent way, we need to ensure that changes to concourse pipelines are applied automatically.\r\n\r\nTo do so, we will add a initial task in each pipeline to update the pipeline itself using the code from the repository.\r\n\r\nNotes:\r\n\r\n - The \"environment class\" specific variables will be set in `Makefile` file, with some sensible defaults defined in code.  In `dev` environments some parameters can be optionally overwritten using environment variables.\r\n\r\n - Self-update will be disabled by default in the dev environments, as we want to be able to apply changes without having to commit and push the code.\r\n\r\n - We won't add logic to lock the pipeline as it is out of the scope for this story.\r\n\r\n - Following the Boy Scouts rule, we try simplify the environment class variable definition in the Makefile.\r\n\r\n\r\nDependencies\r\n---------------------\r\n\r\n - docker container for https://github.com/alphagov/paas-docker-cloudfoundry-tools/pull/35  must be merged before this one.\r\n - The previous container must be created in government-paas dockerhub account and the reference changed in this PR. (https://hub.docker.com/r/governmentpaas/self-update-pipelines/)\r\n\r\n\r\nHow to test this?\r\n---------------------\r\n\r\nDeploy the environment, but enabling self-update (which is disabled in dev by default), and commit some change to the pipeline. \r\n\r\nI recommend use a temporary branch for this, and pause the job after `init`:\r\n\r\n```\r\ngit checkout 114000923_self_updating_pipelines_v2\r\ngit checkout -b 114000923_self_updating_pipelines_review_$(USER) # Create a temporary branch\r\n\r\nSELF_UPDATE_PIPELINE=true BRANCH=$(git rev-parse --abbrev-ref HEAD) make dev\r\n```\r\n\r\nDeploy the environment and observe that in the job `init` the self-update pipeline works and do not do any change.\r\n\r\nThen add some changes in the pipeline and commit and push the changes. Rerunning the `init` job should show that the pipeline is updated.\r\n\r\nYou can do the same for:\r\n - `destroy-microbosh`, `destroy-cloudfoundry` and `failure-testing`\r\n - using `ci`, `staging` and `prod` targets (in that case export the variable `URSE_URL=https://deployer.hector.dev.paas.alphagov.co.uk`)\r\n\r\nWho?\r\n------\r\n\r\nAnyone but @saliceti, @keymon or @HenryTK","created_at":"2016-03-14T13:24:33Z","updated_at":"2016-03-14T15:14:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e7dbfaf0f5e9885cdbac7bfee2953cf359ff6289","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/alphagov/paas-cf/pulls/156/commits","review_comments_url":"https://api.github.com/repos/alphagov/paas-cf/pulls/156/comments","review_comment_url":"https://api.github.com/repos/alphagov/paas-cf/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alphagov/paas-cf/issues/156/comments","statuses_url":"https://api.github.com/repos/alphagov/paas-cf/statuses/911896c17f66ac5108b3439efab1320de1f706c7","head":{"label":"alphagov:114000923_self_updating_pipelines_v2","ref":"114000923_self_updating_pipelines_v2","sha":"911896c17f66ac5108b3439efab1320de1f706c7","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"repo":{"id":46716359,"name":"paas-cf","full_name":"alphagov/paas-cf","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphagov/paas-cf","description":"Government PaaS - Cloud Foundry","fork":false,"url":"https://api.github.com/repos/alphagov/paas-cf","forks_url":"https://api.github.com/repos/alphagov/paas-cf/forks","keys_url":"https://api.github.com/repos/alphagov/paas-cf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/paas-cf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/paas-cf/teams","hooks_url":"https://api.github.com/repos/alphagov/paas-cf/hooks","issue_events_url":"https://api.github.com/repos/alphagov/paas-cf/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/paas-cf/events","assignees_url":"https://api.github.com/repos/alphagov/paas-cf/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/paas-cf/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/paas-cf/tags","blobs_url":"https://api.github.com/repos/alphagov/paas-cf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/paas-cf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/paas-cf/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/paas-cf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/paas-cf/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/paas-cf/languages","stargazers_url":"https://api.github.com/repos/alphagov/paas-cf/stargazers","contributors_url":"https://api.github.com/repos/alphagov/paas-cf/contributors","subscribers_url":"https://api.github.com/repos/alphagov/paas-cf/subscribers","subscription_url":"https://api.github.com/repos/alphagov/paas-cf/subscription","commits_url":"https://api.github.com/repos/alphagov/paas-cf/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/paas-cf/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/paas-cf/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/paas-cf/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/paas-cf/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/paas-cf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/paas-cf/merges","archive_url":"https://api.github.com/repos/alphagov/paas-cf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/paas-cf/downloads","issues_url":"https://api.github.com/repos/alphagov/paas-cf/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/paas-cf/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/paas-cf/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/paas-cf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/paas-cf/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/paas-cf/releases{/id}","deployments_url":"https://api.github.com/repos/alphagov/paas-cf/deployments","created_at":"2015-11-23T11:36:57Z","updated_at":"2016-03-01T11:37:19Z","pushed_at":"2016-03-14T15:14:29Z","git_url":"git://github.com/alphagov/paas-cf.git","ssh_url":"git@github.com:alphagov/paas-cf.git","clone_url":"https://github.com/alphagov/paas-cf.git","svn_url":"https://github.com/alphagov/paas-cf","homepage":null,"size":1348,"stargazers_count":9,"watchers_count":9,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":9,"default_branch":"master"}},"base":{"label":"alphagov:master","ref":"master","sha":"282aec36a97306178883f6c6cc7f918143676bb0","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"repo":{"id":46716359,"name":"paas-cf","full_name":"alphagov/paas-cf","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphagov/paas-cf","description":"Government PaaS - Cloud Foundry","fork":false,"url":"https://api.github.com/repos/alphagov/paas-cf","forks_url":"https://api.github.com/repos/alphagov/paas-cf/forks","keys_url":"https://api.github.com/repos/alphagov/paas-cf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/paas-cf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/paas-cf/teams","hooks_url":"https://api.github.com/repos/alphagov/paas-cf/hooks","issue_events_url":"https://api.github.com/repos/alphagov/paas-cf/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/paas-cf/events","assignees_url":"https://api.github.com/repos/alphagov/paas-cf/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/paas-cf/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/paas-cf/tags","blobs_url":"https://api.github.com/repos/alphagov/paas-cf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/paas-cf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/paas-cf/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/paas-cf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/paas-cf/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/paas-cf/languages","stargazers_url":"https://api.github.com/repos/alphagov/paas-cf/stargazers","contributors_url":"https://api.github.com/repos/alphagov/paas-cf/contributors","subscribers_url":"https://api.github.com/repos/alphagov/paas-cf/subscribers","subscription_url":"https://api.github.com/repos/alphagov/paas-cf/subscription","commits_url":"https://api.github.com/repos/alphagov/paas-cf/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/paas-cf/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/paas-cf/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/paas-cf/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/paas-cf/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/paas-cf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/paas-cf/merges","archive_url":"https://api.github.com/repos/alphagov/paas-cf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/paas-cf/downloads","issues_url":"https://api.github.com/repos/alphagov/paas-cf/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/paas-cf/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/paas-cf/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/paas-cf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/paas-cf/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/paas-cf/releases{/id}","deployments_url":"https://api.github.com/repos/alphagov/paas-cf/deployments","created_at":"2015-11-23T11:36:57Z","updated_at":"2016-03-01T11:37:19Z","pushed_at":"2016-03-14T15:14:29Z","git_url":"git://github.com/alphagov/paas-cf.git","ssh_url":"git@github.com:alphagov/paas-cf.git","clone_url":"https://github.com/alphagov/paas-cf.git","svn_url":"https://github.com/alphagov/paas-cf","homepage":null,"size":1348,"stargazers_count":9,"watchers_count":9,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alphagov/paas-cf/pulls/156"},"html":{"href":"https://github.com/alphagov/paas-cf/pull/156"},"issue":{"href":"https://api.github.com/repos/alphagov/paas-cf/issues/156"},"comments":{"href":"https://api.github.com/repos/alphagov/paas-cf/issues/156/comments"},"review_comments":{"href":"https://api.github.com/repos/alphagov/paas-cf/pulls/156/comments"},"review_comment":{"href":"https://api.github.com/repos/alphagov/paas-cf/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alphagov/paas-cf/pulls/156/commits"},"statuses":{"href":"https://api.github.com/repos/alphagov/paas-cf/statuses/911896c17f66ac5108b3439efab1320de1f706c7"}}}}