Git Product home page Git Product logo

git-resource's Introduction

Git Resource

Tracks the commits in a git repository.

Source Configuration

  • uri: Required. The location of the repository.

  • branch: The branch to track. This is optional if the resource is only used in get steps; however, it is required when used in a put step. If unset, get steps will checkout the repository's default branch; usually master but could be different.

  • private_key: Optional. Private key to use when pulling/pushing. Example:

    private_key: |
      -----BEGIN RSA PRIVATE KEY-----
      MIIEowIBAAKCAQEAtCS10/f7W7lkQaSgD/mVeaSOvSF9ql4hf/zfMwfVGgHWjj+W
      <Lots more text>
      DWiJL+OFeg9kawcUL6hQ8JeXPhlImG6RTUffma9+iGQyyBMCGd1l
      -----END RSA PRIVATE KEY-----
  • private_key_user: Optional. Enables setting User in the ssh config.

  • private_key_passphrase: Optional. To unlock private_key if it is protected by a passphrase.

  • forward_agent: Optional Enables ForwardAgent SSH option when set to true. Useful when using proxy/jump hosts. Defaults to false.

  • username: Optional. Username for HTTP(S) auth when pulling/pushing. This is needed when only HTTP/HTTPS protocol for git is available (which does not support private key auth) and auth is required.

  • password: Optional. Password for HTTP(S) auth when pulling/pushing.

  • paths: Optional. If specified (as a list of glob patterns), only changes to the specified files will yield new versions from check.

  • ignore_paths: Optional. The inverse of paths; changes to the specified files are ignored.

    Note that if you want to push commits that change these files via a put, the commit will still be "detected", as check and put both introduce versions. To avoid this you should define a second resource that you use for commits that change files that you don't want to feed back into your pipeline - think of one as read-only (with ignore_paths) and one as write-only (which shouldn't need it).

  • skip_ssl_verification: Optional. Skips git ssl verification by exporting GIT_SSL_NO_VERIFY=true.

  • tag_filter: Optional. If specified, the resource will only detect commits that have a tag matching the expression that have been made against the branch. Patterns are glob(7) compatible (as in, bash compatible).

  • tag_regex: Optional. If specified, the resource will only detect commits that have a tag matching the expression that have been made against the branch. Patterns are grep compatible (extended matching enabled, matches entire lines only). Ignored if tag_filter is also specified.

  • fetch_tags: Optional. If true the flag --tags will be used to fetch all tags in the repository. If false no tags will be fetched.

  • submodule_credentials: Optional. List of credentials for HTTP(s) or SSH auth when pulling git submodules which are not stored in the same git server as the container repository or are protected by a different private key.

    • http(s) credentials:
      • host : The host to connect too. Note that host is specified with no protocol extensions.
      • username : Username for HTTP(S) auth when pulling submodule.
      • password : Password for HTTP(S) auth when pulling submodule.
    • ssh credentials:
      • url : Submodule url, as specified in the .gitmodule file. Support full or relative ssh url.
      • private_key : Private key for SSH auth when pulling submodule.
      • private_key_passphrase : Optional. To unlock private_key if it is protected by a passphrase.
    • exemple:
      submodule_credentials:
        # http(s) credentials
      - host: github.com
        username: git-user
        password: git-password
        # ssh credentials
      - url: [email protected]:org-name/repo-name.git
        private_key: |
          -----BEGIN RSA PRIVATE KEY-----
          MIIEowIBAAKCAQEAtCS10/f7W7lkQaSgD/mVeaSOvSF9ql4hf/zfMwfVGgHWjj+W
          <Lots more text>
          DWiJL+OFeg9kawcUL6hQ8JeXPhlImG6RTUffma9+iGQyyBMCGd1l
          -----END RSA PRIVATE KEY-----
        private_key_passphrase: ssh-passphrase # (optionnal)
        # ssh credentials with relative url
      - url: ../org-name/repo-name.git
        private_key: |
          -----BEGIN RSA PRIVATE KEY-----
          MIIEowIBAAKCAQEAtCS10/f7W7lkQaSgD/mVeaSOvSF9ql4hf/zfMwfVGgHWjj+W
          <Lots more text>
          DWiJL+OFeg9kawcUL6hQ8JeXPhlImG6RTUffma9+iGQyyBMCGd1l
          -----END RSA PRIVATE KEY-----
        private_key_passphrase: ssh-passphrase # (optionnal)
  • git_config: Optional. If specified as (list of pairs name and value) it will configure git global options, setting each name with each value.

    This can be useful to set options like credential.helper or similar.

    See the git-config(1) manual page for more information and documentation of existing git options.

  • disable_ci_skip: Optional. Allows for commits that have been labeled with [ci skip] or [skip ci] previously to be discovered by the resource.

  • commit_verification_keys: Optional. Array of GPG public keys that the resource will check against to verify the commit (details below).

  • commit_verification_key_ids: Optional. Array of GPG public key ids that the resource will check against to verify the commit (details below). The corresponding keys will be fetched from the key server specified in gpg_keyserver. The ids can be short id, long id or fingerprint.

  • gpg_keyserver: Optional. GPG keyserver to download the public keys from. Defaults to hkp://keyserver.ubuntu.com/.

  • git_crypt_key: Optional. Base64 encoded git-crypt key. Setting this will unlock / decrypt the repository with git-crypt. To get the key simply execute git-crypt export-key -- - | base64 in an encrypted repository.

  • https_tunnel: Optional. Information about an HTTPS proxy that will be used to tunnel SSH-based git commands over. Has the following sub-properties:

    • proxy_host: Required. The host name or IP of the proxy server
    • proxy_port: Required. The proxy server's listening port
    • proxy_user: Optional. If the proxy requires authentication, use this username
    • proxy_password: Optional. If the proxy requires authenticate, use this password
  • commit_filter: Optional. Object containing commit message filters

    • exclude: Optional. Array containing strings that should cause a commit to be skipped
    • include: Optional. Array containing strings that MUST be included in commit messages for the commit to not be skipped

    Note: You must escape any regex sensitive characters, since the string is used as a regex filter.
    For example, using [skip deploy] or [deploy skip] to skip non-deployment related commits in a deployment pipeline:

    commit_filter:
      exclude: ["\\[skip deploy\\]", "\\[deploy skip\\]"]
  • version_depth: Optional. The number of versions to return when performing a check

  • search_remote_refs: Optional. True to search remote refs for the input version when checking out during the get step. This can be useful during the get step after a put step for unconventional workflows. One example workflow is the refs/for/<branch> workflow used by gerrit which 'magically' creates a refs/changes/nnn reference instead of the straight forward refs/for/<branch> reference that a git remote would usually create. See also out params.refs_prefix.

Example

Resource configuration for a private repo with an HTTPS proxy:

resources:
- name: source-code
  type: git
  source:
    uri: [email protected]:concourse/git-resource.git
    branch: master
    private_key: |
      -----BEGIN RSA PRIVATE KEY-----
      MIIEowIBAAKCAQEAtCS10/f7W7lkQaSgD/mVeaSOvSF9ql4hf/zfMwfVGgHWjj+W
      <Lots more text>
      DWiJL+OFeg9kawcUL6hQ8JeXPhlImG6RTUffma9+iGQyyBMCGd1l
      -----END RSA PRIVATE KEY-----
    git_config:
    - name: core.bigFileThreshold
      value: 10m
    disable_ci_skip: true
    git_crypt_key: AEdJVEN...snip...AAA==
    https_tunnel:
      proxy_host: proxy-server.mycorp.com
      proxy_port: 3128
      proxy_user: myuser
      proxy_password: myverysecurepassword

Resource configuration for a private repo with a private submodule from different git server:

resources:
- name: source-code
  type: git
  source:
    uri: [email protected]:concourse/git-resource.git
    branch: master
    submodule_credentials:
    - host: some.other.git.server
      username: user
      password: verysecurepassword
    private_key: |
      -----BEGIN RSA PRIVATE KEY-----
      MIIEowIBAAKCAQEAtCS10/f7W7lkQaSgD/mVeaSOvSF9ql4hf/zfMwfVGgHWjj+W
      <Lots more text>
      DWiJL+OFeg9kawcUL6hQ8JeXPhlImG6RTUffma9+iGQyyBMCGd1l
      -----END RSA PRIVATE KEY-----

Fetching a repo with only 100 commits of history:

- get: source-code
  params: {depth: 100}

Pushing local commits to the repo:

- get: some-other-repo
- put: source-code
  params: {repository: some-other-repo}

Fetching a repo pinned to a specific commit:

resources:
- name: source-code
  type: git
  source:
    uri: [email protected]:concourse/git-resource.git
    branch: master
  version:
    ref: commit-sha

Behavior

check: Check for new commits

The repository is cloned (or pulled if already present), and any commits from the given version on are returned. If no version is given, the ref for HEAD is returned.

Any commits that contain the string [ci skip] will be ignored. This allows you to commit to your repository without triggering a new version.

in: Clone the repository, at the given ref

Clones the repository to the destination, and locks it down to a given ref. It will return the same given ref as version.

git-crypt encrypted repositories will automatically be decrypted, when the correct key is provided set in git_crypt_key.

Parameters

  • depth: Optional. If a positive integer is given, shallow clone the repository using the --depth option. To prevent newer commits that do not pass a paths filter test from skewing the cloned history away from version.ref, this resource will automatically deepen the clone until version.ref is found again. It will deepen with exponentially increasing steps until a maximum of 127 + depth commits or else resort to unshallow the repository.

  • fetch_tags: Optional. If true the flag --tags will be used to fetch all tags in the repository. If false no tags will be fetched.

    Will override fetch_tags source configuration if defined.

  • submodules: Optional. If none, submodules will not be fetched. If specified as a list of paths, only the given paths will be fetched. If not specified, or if all is explicitly specified, all submodules are fetched.

  • submodule_recursive: Optional. If false, a flat submodules checkout is performed. If not specified, or if true is explicitly specified, a recursive checkout is performed.

  • submodule_remote: Optional. If true, the submodules are checked out for the specified remote branch specified in the .gitmodules file of the repository. If not specified, or if false is explicitly specified, the tracked sub-module revision of the repository is used to check out the submodules.

  • disable_git_lfs: Optional. If true, will not fetch Git LFS files.

  • clean_tags: Optional. If true all incoming tags will be deleted. This is useful if you want to push tags, but have reasonable doubts that the tags cached with the resource are outdated. The default value is false.

  • short_ref_format: Optional. When populating .git/short_ref use this printf format. Defaults to %s.

  • timestamp_format: Optional. When populating .git/commit_timestamp use this options to pass to git log --date. Defaults to iso8601.

  • describe_ref_options: Optional. When populating .git/describe_ref use this options to call git describe. Defaults to --always --dirty --broken.

GPG signature verification

If commit_verification_keys or commit_verification_key_ids is specified in the source configuration, it will additionally verify that the resulting commit has been GPG signed by one of the specified keys. It will error if this is not the case.

Additional files populated

  • .git/committer: For committer notification on failed builds. This special file .git/committer which is populated with the email address of the author of the last commit. This can be used together with an email resource like mdomke/concourse-email-resource to notify the committer in an on_failure step.

  • .git/ref: Version reference detected and checked out. It will usually contain the commit SHA-1 ref, but also the detected tag name when using tag_filter or tag_regex.

  • .git/branch: Name of the original branch that was cloned.

  • .git/short_ref: Short (first seven characters) of the .git/ref. Can be templated with short_ref_format parameter.

  • .git/commit_message: For publishing the Git commit message on successful builds.

  • .git/commit_timestamp: For tagging builds with a timestamp.

  • .git/describe_ref: Version reference detected and checked out. Can be templated with describe_ref_options parameter. By default, it will contain the <latest annoted git tag>-<the number of commit since the tag>-g<short_ref> (eg. v1.6.2-1-g13dfd7b). If the repo was never tagged before, this falls back to a short commit SHA-1 ref.

out: Push to a repository

Push the checked-out reference to the source's URI and branch. All tags are also pushed to the source. If a fast-forward for the branch is not possible and the rebase parameter is not provided, the push will fail.

Parameters

  • repository: Required. The path of the repository to push to the source.

  • rebase: Optional. If pushing fails with non-fast-forward, continuously attempt rebasing and pushing.

  • merge: Optional. If pushing fails with non-fast-forward, continuously attempt to merge remote to local before pushing. Only one of merge or rebase can be provided, but not both.

  • returning: Optional. When passing the merge flag, specify whether the merge commit or the original, unmerged commit should be passed as the output ref. Options are merged and unmerged. Defaults to merged.

  • tag: Optional. If this is set then HEAD will be tagged. The value should be a path to a file containing the name of the tag.

  • only_tag: Optional. When set to 'true' push only the tags of a repo.

  • tag_prefix: Optional. If specified, the tag read from the file will be prepended with this string. This is useful for adding v in front of version numbers.

  • force: Optional. When set to 'true' this will force the branch to be pushed regardless of the upstream state.

  • annotate: Optional. If specified the tag will be an annotated tag rather than a lightweight tag. The value should be a path to a file containing the annotation message.

  • notes: Optional. If this is set then notes will be added to HEAD to the refs/notes/commits ref. The value should be a path to a file containing the notes.

  • branch: Optional. The branch to push commits.

    Note that the version produced by the put step will be picked up by subsequent get steps even if the branch differs from the branch specified in the source. To avoid this, you should use two resources of read-only and write-only.

  • refs_prefix: Optional. Allows pushing to refs other than heads. Defaults to refs/heads.

    Useful when paired with source.search_remote_refs in cases where the git remote renames the ref you pushed.

Development

Prerequisites

  • golang is required - version 1.9.x is tested; earlier versions may also work.
  • docker is required - version 17.06.x is tested; earlier versions may also work.

Running the tests

The tests have been embedded with the Dockerfile; ensuring that the testing environment is consistent across any docker enabled platform. When the docker image builds, the test are run inside the docker container, on failure they will stop the build.

Run the tests with the following command:

docker build -t registry-image-resource --target tests --build-arg base_image=paketobuildpacks/run-jammy-base:latest .

Note about the integration tests

If you want to run the integration tests, a bit more work is required. You will require an actual git repo to which you can push and pull, configured for SSH access. To do this, add two files to integration-tests/ssh (note that names are important):

  • test_key: This is the private key used to authenticate against your repo.
  • test_repo: This file contains one line of the form test_repo_url[#test_branch]. If the branch is not specified, it defaults to master. For example, [email protected]:concourse-git-tester/git-resource-integration-tests.git or [email protected]:concourse-git-tester/git-resource-integration-tests.git#testing

Contributing

Please make all pull requests to the master branch and ensure tests pass locally.

git-resource's People

Contributors

agrrh avatar alext avatar alucillo avatar aoldershaw avatar davidb avatar fenech avatar fmy avatar goddenrich avatar heldersepu avatar hy0044 avatar jamie-pate avatar jdziat avatar keymon avatar krishicks avatar luan avatar mariash avatar ngehrsitz avatar norbertbuchmueller avatar oppegard avatar pivotal-bin-ju avatar ppaulweber avatar shyx0rmz avatar simonjohansson avatar talset avatar taylorsilva avatar vito avatar xoebus avatar xtremerui avatar youssb avatar zachgersh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

git-resource's Issues

Git check hangs indefinitely

I'm running Concourse 2.1.0 and occasionally see git resources lock up. In happens across all pipelines without any error message. Attempting a check-resource via fly also hangs with no output. This seems similar to #68, although I'm not using btrfs.

I've tried aborting and restarting jobs without any luck. I've also left a job running overnight but came back to it still waiting on the git resource. Deleting and recreating the pipeline does allow it to immediately succeed.

submodules of submodules seem to be borked in new git resource version

After cloning cf-release I see the following when running git status:

fatal: Not a git repository: /tmp/build/get/.git/modules/src/capi-release/modules/src/cloud_controller_ng
fatal: 'git status --porcelain' failed in submodule src/capi-release

Here is a pipeline that can recreate the issue on concourse v1.3.0:

resources:
- name: cf-release
  type: git
  source:
    uri: https://github.com/cloudfoundry/cf-release.git
    branch: master

jobs:
- name: check-status
  plan:
  - aggregate:
    - get: cf-release
      resource: cf-release
  - task: status
    config:
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: pivotalcfreleng/minimal
      inputs:
      - name: cf-release
      run:
        path: /usr/bin/git
        args:
        - status
        dir: cf-release

Not triggering on a merge commit, or not triggering after branch config change

Using BDD style description, because it's what I know.

Given

I have a branch called foo
Foo is a feature branch off develop
My git resource is configured as branch: foo
The last check of my git resource pointed to sha aaa

When

I merged foo to develop as a merging commit - creating sha bbb
And pushed develop to github
And updated my git resource config to branch: develop
And fly configured concourse

Then

My git resource never triggered with bbb
And I waited a long time

When

I commited another change to develop - creating sha ccc

Then

My git resource triggered with ccc
And never showed bbb

Git resource occasionally refuses to connect to repo(s)

We are running 1.4.1 and find that randomly, a git resource which has worked fine will refuse to pull from a repo which has new commits available.

There are no errors, the resource simply spins and never times out.

This is a random issue that affects most of our pipelines which normally work without an issue.

Anyone else experience a similar issue?

Ability to disable git LFS

We use git lfs for some development dependencies (~2GB of them) but we don't need them on CI (and it slows down the builds enormously).

It looks like it should be as easy as adding a param like disable_git_lfs and adding an if to the inputs script. Does that sound reasonable if I make a PR?

recursive submodules and triggering

Hi,

I just wonder about the following scenario:

GitRepoA*
+--- SubmoduleAA*
:    +--- SubmoduleAAA
     |    +--- fileAAAA
     |    +--- fileAAAB
     +--- SubmoduleAAB*
     :    :

SubSubModule AAB has changed, therefore SubmoduleAA and GitRepoA were changed, too (new submodule commits). SubmoduleAAA has no changes.

If GitRepoA is my source-uri, how do I express that I get triggered only if I had a change on fileAAAB? Just setting "paths: [SubmoduleAA/SubmoduleAAA/fileAAAB]" ???

Best regards, Stephan

Detecting multiple tags via filter

/cc @Jonty

Opening a separate issue to augment tag_filter. It would be nice if it could support the full resource interface, part of which defines that it should be possible to discover old versions, and ranges of versions, not just the latest.

Something like this might work pretty well (replacing the git describe that we currently do):

git tag --list <pattern> --sort=creatordate [--contains <cursor>]

Example, run from buildroot which has date-formatted tags and RCs:

~/w/buildroot (master) $ git tag --list "*.*" --sort=creatordate --contains 2015.08
2015.08
2015.08.1
2015.11-rc1
2015.11-rc2
2015.11-rc3
2015.11
2015.11.1
2016.02-rc1
2016.02-rc2
2016.02-rc3
2016.02
2016.05-rc1
2016.05-rc2
2016.05-rc3
2016.05

(...which brings up another point: how to omit RCs?)

And another example, in concourse/concourse:

~/w/concourse (develop) $ git tag --list "v*" --sort=creatordate
v0.14.0
v0.15.0
v0.16.0
v0.17.0
v0.18.0
v0.19.0
v0.20.0
v0.21.0
v0.22.0
v0.23.0
v0.24.0
v0.25.0
v0.26.0
v0.27.0
v0.28.0
v0.29.0
v0.30.0
v0.31.0
v0.32.0
v0.33.0
v0.34.0
v0.35.0
v0.36.0
v0.37.0
v0.38.0
v0.39.0
v0.40.0
v0.41.0
v0.42.0
v0.43.0
v0.44.0
v0.45.0
v0.46.0
v0.47.0
v0.48.0
v0.49.0
v0.50.0
v0.51.0
v0.52.0
v0.53.0
v0.54.0
v0.55.0
v0.56.0
v0.57.0
v0.58.0
v0.59.0
v0.59.1
v0.60.0
v0.60.1
v0.61.0
v0.62.0
v0.62.1
v0.63.0
v0.64.0
v0.64.1
v0.65.0
v0.65.1
v0.66.0
v0.66.1
v0.67.0
v0.67.1
v0.68.0
v0.69.0
v0.69.1
v0.70.0
v0.71.0
v0.71.1
v0.72.0
v0.72.1
v0.73.0
v0.74.0
v0.75.0
v0.76.0
v1.0.0
v1.0.1
v1.1.0
v1.2.0
~/w/concourse (develop) $ git tag --list "v*" --sort=creatordate --contains v1.0.1
v1.0.1
v1.1.0
v1.2.0
~/w/concourse (develop) $

Merge commits not being detected

At some point recently (I think it's recent), merge commits have stopped being detected. For example, given a repository's commit log:

screen shot 2016-04-11 at 15 04 33

and the resource history:

screen shot 2016-04-11 at 15 04 02

Note that the following commits aren't listed:

  • 76730de
  • be5d390
  • 52d3397
  • c135c4d

The common thread is that these are all merge commits. We use merge commits to delineate units of work, but the thing that has flagged this for us is that we use them to trigger Pivotal Tracker transitions.

screen shot 2016-04-11 at 15 08 54

Should the in script reuse the clone maintained by the check script?

Firstly, i should say that i am still trying to get my head round how this resource works, so i might have the wrong end of the stick here.

This is an idea for an enhancement.

The 'check' script does this:

destination=$TMPDIR/git-resource-repo-cache

if [ -d $destination ]; then
  cd $destination
  git fetch
  git reset --hard FETCH_HEAD

Which means that if the resource container is reused, it will do incremental fetches from the origin into $TMPDIR/git-resource-repo-cache to get new commits.

The 'in' script does this:

cat > $payload <&0
# ...
uri=$(jq -r '.source.uri // ""' < $payload)
# ...
git clone --single-branch $depthflag $uri $branchflag $destination

Which means that it's always pulling a fresh (albeit possibly shallow) clone from the origin.

Would it be possible for the 'in' script to clone from $TMPDIR/git-resource-repo-cache instead? That means the clone would be purely local, and would not need to go out to the network again.

You'd need to make sure it was a standalone clone, not using hardlinks or sharing or whatever, but there are flags for that.

I appreciate that you probably want the clone's remote to be the real origin, not the local cache, but that can be arranged. Perhaps do a clone from the origin with --depth 0 (is that allowed?) then do a pull from the local cache. Or else clone, then use git remote to rewrite the remote. You'd need to do something about tracking branches too.

You'd need to allow for the case where 'in' is asked for a version of the repository which isn't in the cache (say because the resource container was deleted in between the 'check' and the 'in'). You could deal with that by checking to see if the version is there, and if not, calling into the 'check' machinery to create and update the cache.

File containing sha of HEAD

It'd be handy if there was a file containing the sha of the git repo checked out. Currently, the way to get this is via git rev-parse HEAD.

Fails to clone private submodules

It seems that it does not use ssh key to do submodule init. I can clone my repo and its submodules separately (using the same ssh key) and each succeeds, but unless I say { submodules: none } when doing the get on the parent, the parent fails to clone with:

Identity added: /tmp/git-resource-private-key (/tmp/git-resource-private-key)
Cloning into '/tmp/build/get'...
Fetching HEAD
843d29e Rename some concourse stuff
Submodule 'src/main/resources/[redacted]-secrets' (git@[redacted].git) registered for path 'src/main/resources/[redacted]-secrets'
Cloning into '/tmp/build/get/src/main/resources/[redacted]-secrets'...
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git@[redacted].git' into submodule path '/tmp/build/get/src/main/resources/[redacted]-secrets' failed

HTTPS auth doesn't work

Git resources using https auth don't seem to function at all.

Using this setup:

resources:
- name: reponame
  type: git
  source:
    uri: https://github.com/companyname/reponame.git
    branch: master
    username: githubusername
    password: githubpassword

The check script fails with the following error message:

resource script '/opt/resource/check []' failed: exit status 128

stderr:
Cloning into '/tmp/git-resource-repo-cache'...
fatal: could not read Username for 'https://github.com': No such device or address

HTTPS auth is important because you can't authenticate submodules using private keys. Thanks!

path: dir/**/* not triggering

We have a pipeline that is not getting triggered on a change to dir/file.md when defining the glob dir/**/*. When using dir/* it works.

Locally the commands git log --format='%H' --reverse $ref..HEAD -- dir/**/* and git log --format='%H' --reverse $ref..HEAD -- dir/* produce the same output.

git-resource not ignoring submodules when using put

Hi,
We have a pipeline where the get params include a list of submodules that should be cloned. This works fine when checking out the source-code before building. However after building we push a tag back to the repository and this is where the problem occurs.

After the tag is pushed the source-code is pulled again, this time all submodules are cloned. How can we avoid this full submodule clone?

Best regards Andreas Knifh

Attempts to add a private key with a passphrase for SSH fail silently

If you give Concourse an SSH private key that has a passphrase the only error you will see is when you click the resource is something like unable to check. Only experienced Concoursers recognize the missing hashes for a git resource and suggest connectivity problems with the private key. We figured the issue out but I figured I would create an issue in the hopes some kind of relatively simple check can be added to help future devs.

Can't push without tags

A put command to a github resource is always a git push --tag. We use tags to mark release versions and commits deployed to specific environments. Right now, we have to delete all tags locally in our scripts before pushing from Concourse. We would prefer to be able to just specify in our plan configuration that we don't want to push tags, or for this to be the default behavior.

When configured with depth N, /in should still be able to fetch a ref N+1 commits ago

The git repository check determines the SHA limited to the paths that are not filtered. When the resource is obtained at getting phase with depth - the depth is based on the overall repository. This difference results in git failing because the target sha is unrecognizable.

Philosophically speaking since the resource is limited to several paths - the depth parameter in the get operation should be considered as depth for the filtered paths - not the overall repo. Easier said than done, though. There are strategies to obtain the needed depth - check this question for ideas: http://stackoverflow.com/questions/39935546/get-git-sha-depth-on-a-remote-branch/39941969#39941969

Note that since the resource check is cloning the whole repo - if there is a mechanism to store the current depth - it can be used as starting point and this will reduce significantly the number of iterations until it gets to the right one.

As a hot patch, the depth might be ignored - if filters on paths are used ... or it might be reported as an issue when the pipeline validation is made. Note that the connection combining these two will result in "random" failures is hard to make.

Support pushing via HTTPS and basic auth

Some environments only allow HTTP(S) traffic into the Git repository; and so need to use https:// protocol with basic auth credentials; rather than private key

Support shallow cloning

For large repos with years of history, it'd be useful to support the --depth option when cloning a repo.

variables don't expand properly in uri

Curly bracket expansion doesn't play nice when used as part of a URI:

resources:
- name: tools
  type: git
  source:
    uri: [email protected]:{{github-username}}/tools.git
    branch: master
    private_key: {{github-private-key}}

jobs:
- name: test
  plan:
  - get: tools

After set-pipeline passing --var github-username=bacoboy expands with extra quotes:

      uri: [email protected]:"bacoboy"/tools.git

This results in a resource error:

resource script '/opt/resource/check []' failed: exit status 128

stderr:
Identity added: /tmp/git-resource-private-key (/tmp/git-resource-private-key)
Cloning into '/tmp/git-resource-repo-cache'...
fatal: remote error: 
  %s is not a valid repository name
  Email [email protected] for help

Clone submodules in parallel

There is no reason this needs to be done serially. You could add something like this:

git submodule status | awk '{print $2}' | xargs -P5 -n1 git submodule update --init $depthflag --recursive

here:

git-resource/assets/in

Lines 59 to 66 in d3fc957

if [ "$submodules" == "all" ]; then
git submodule update --init $depthflag --recursive
elif [ "$submodules" != "none" ]; then
submodules=$(echo $submodules | jq -r '(.[])')
for submodule in $submodules; do
git submodule update --init $depthflag --recursive $submodule
done
fi

giphy

I'll do a PR if you want.

add support for shallow submodules

Currently, no --depth parameter is applied when doing git submodule update --init --recursive $submodule

We have a large submodule that we'd like to clone shallowly.

Better diagnostics when required settings not found

I just wasted a non-trivial amount of time figuring out why git-resource wouldn't work for checking out a repo via ssh.

Turns out I was using private-key: instead of private_key: in my pipeline.yml

In both cases, fly set-pipeline happily accepted my inputs, letting me down only when trying to check the resource, with this error

$ fly -t local cr -r test/resource-tutorial
error: check failed with exit status '128':
Cloning into '/tmp/git-resource-repo-cache'...
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights

(see also #66 (comment))

At least git-resource should both provide proper diagnostics and check that it actually has a private key specified when trying to check out an ssh repo. A warning statement about missing settings in the output returned by fly would be good enough already.

Bettery yet, fly set-pipeline should validate the yml file, though that may be a lot more difficult

`paths` option broken for merge commits

If you have a paths option, then the check script will fail to trigger for merge commits even if the commits which they merged in contained changes to files which are included in paths.

Presumably this is because of the shallow clone, so there's NO files included in the merge commit.

`[ci skip]` not respected

commits with [ci skip] are now showing up inside our git resources and triggering builds looking at the repo in question is public should allow reproduction of the issue.

Local git version: git version 2.5.0
Version of git inside container which made commit: git version 1.9.1

source.uri is case-sensitive

We have a repo on github under the Company-ProductGroup org name, let's call it Company-ProductGroup/instrumentation

When we wrote and tried to use a pipeline with the source.uri value of [email protected]:company-productgroup/instrumentation.git, the git clone failed. Correcting the capitalization of the org name let things carry on correctly.

We would expect that github org names are not case-sensitive.

git history can get borked

Our git-resource for cf-deployment is having a few problems.

First, it seems to fetch the wrong branch. The desired branch is develop, which is at SHA 210655a. Instead, it seems to be fetching fa43ce from a 5-month-old WIP branch that we've since deleted. There hasn't been any activity on this branch, but for some reason, the three commits on this branch are the three topmost versions of git resource in the concourse UI.

Second, even without the inclusion of this WIP branch, the remainder of the history is missing the most recent commits on develop.

screen shot 2016-03-04 at 12 12 10 pm
screen shot 2016-03-04 at 12 12 36 pm

As you can see, ref 3e48b is the most recent commit in the history of develop that the git resource his picked up (it doesn't seem to have found refs 2782123, 9f545d2, or 210655a, even though they are all in the history of develop).

We're not sure what's causing this, or how to find out the root cause. (We were trying to delete a bunch of data from the build_events table. We're not sure how this would affect resource versions, but it could be that something was going wrong wit hthe db.) We're going to work around it by re-building the pipeline.

`annotate` param should be relative to the container, not the repo

It's worth noting that the filename for the 'tag:' parameter needs to be expressed relative to the base of the container (e.g.: version/number), whereas the filename for the 'annotate:' parameter needs to be expressed relative to the base of the git repository (e.g.: ../version/number)

Not too difficult to figure that out by reading the source, but it's a surprising piece of information that should probably be called out explicitly in the documentation.

Add support for fetching only single branch

Git fetches all branches by default, and this resource is following this schema. I had small master branch (~1MB) with few other big branches (~0.5GB), simple getting the master took like 2-3 minutes. git clone done manually in shell did the same - and downloaded 0.5GB of data. Deleting big remote branches helped for me, this resource started getting master in few seconds instead.

git clone -b mybranch --single-branch git://sub.domain.com/repo.git

Clarify supported git url schemes

Hi,
first steps with Concourse CI for me, first of all thanks for that great tool with interesting different concepts. :)

I've tried to connect a git-resource to my private git repository (not hosted on github). Is it the case that only the scp-like url scheme git@...:/path/to/repo.git/ is supported? I've tried several attempts similar to the following ones, but only the last one seems to work (all the others fail with fatal: Could not read from remote repository.). I've specified the correct private_key, btw.

ssh://example.com:1234/path/to/repo.git/
git://example.com:1234/path/to/repo.git/
[email protected]:/path/to/repo.git/

The first schemes are needed if you want to specify a different port other than 22.

Also local directory repositories don't seem to work, neither with /path/to/repo.git/ nor file:///path/to/repo.git/.

Could you please confirm or clarify in the documentation what is supported?

Add git-crypt support.

I would like to try out concourse, but almost all of my repos are encrypted with git-crypt.

So I was thinking about adding git-crypt support and sending a PR, is this something you are interested in?

Tag behaviors should work for detached HEAD tags

Currently, when specifying a value for tag_filter the only candidates that are considered are the ones that are reachable from the specified (or default) branch. Tags that are detached HEADs (or in other branches) are not considered since they are not retrieved during git fetch <BRANCH>.

In Maven (and Java generally) the version of an application exists in source control. So, when we tag a release, it requires a commit that contains those changes. In the Spring projects, it’s common that master never has a release on it. Version numbers go from one snapshot to another from the perspective of master, and the release hangs off and has to be directly targeted.

screen shot 2016-08-15 at 15 04 34

Based on a Slack conversation I'd like to advocate that any behavior having to do with tags (tag_filter is the only one that's obvious to me) ignore branches completely. All tags, regardless of what they're reachable from HEAD or not, should be considered. This policy should hold true for other future features having to do with tags as well.

Git resource doesn't actually push to git lfs

Hi Folks,

I know we (the data toolsmiths) were the folks who originally submitted the LFS PRs to the git resource, but we discovered they don't work! I am creating this issue to track the fact that it still definitely doesn't work, and we (the data toolsmiths) should probably submit some more PRs to actually make LFS work.

Best,
Zak + @cjcjameson

P.S. Do u ever think about space?

ignore_path option does not work as expected

We have the following ignore paths in our pipeline.

ignore_paths:
  - releases/bosh-openstack-cpi/**
  - .final_builds/**
  - docs/**
  - README.md

We have tested the glob patterns locally with the following command which resembles what the check does in the git-resource:

$ git log --format='%H' -- . ':!.final_builds/**' ':!releases/**' ':!docs/**'

Unfortunately it does not filter expected commits:
https://main.bosh-ci.cf-app.com/pipelines/bosh-openstack-cpi/resources/bosh-cpi-release
(Concours apparently runs in version 0.71.1)

Commits that should not be part of the list are the following:
1ff876e53c2addd4cc2a4b54eaf20e30b7e2fb19
774ec6f200df0a93b3f669cf9bdb4b6d36f4429f

Strange thing is, in our internal concourse (currently 0.71.0) we have the same pipeline set and it works.
(We also have a pipeline where it partially worked, but here we are not fully aware what pipeline-configs have been applied)

Any ideas?

Create a tunnel for using ssh behind proxy git connections

Hi,

In our company is mandatory to use a proxy to connect to internet sites. We have a git repository in internet and only configured for ssh access, so we need to create a tunnel using corkscrew across the proxy (http://www.techrepublic.com/blog/linux-and-open-source/using-corkscrew-to-tunnel-ssh-over-http/).

We tested in ours concourse workers instances and it is working, but for using that in git-resource we need to setup the ssh config.

Before to create a fork to implement this functionality and use it, we want to know if we could implement and donate this code to this repository, and which are the steps to follow to colaborate.

We think that this functionality is useful to big companies with a complex environments, so if you want we can colaborate.

What do you think? Could you answer the questions above?

Thanks,
Carlos León

Allow checking to trigger on tagging, and filter the tags

We'd really like to only trigger some pipelines when we push a new tag marking a release, however we also push other tags so we would like to be able to filter the tags used by the check script.

Obviously the checked-out version would match the latest matching tag that has been pushed.

Opening this here as we've expressed interest in working on it in Slack and were told it would be accepted upstream.

tags-only push

the git resource does not seem to be able to tag a repo at the sha provided to a build, if there have been commits after that sha on the branch.

when we try to do this, we get errors on push if we don't specify rebase, and it tags the wrong sha if we do specify rebase.

a tags-only push would solve this problem for us

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.