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

Config options not being picked up #12

Open
sashahilton00 opened this issue Apr 27, 2021 · 7 comments
Open

Config options not being picked up #12

sashahilton00 opened this issue Apr 27, 2021 · 7 comments
Labels
bug Something isn't working

Comments

@sashahilton00
Copy link

I am seeing some issues when using 3.0.0 with the following configuration:

{
  "branch": "master",
  "preset": "conventionalcommits",
  "plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    "@semantic-release/changelog",
    "@semantic-release/git",
    "@semantic-release/gitlab",
    [
      "@codedependant/semantic-release-docker",
      {
        "dockerTags": [
          "latest",
          "{version}"
        ],
        "dockerImage": "sample-image",
        "dockerRegistry": "registry.gitlab.com",
        "dockerProject": "sample-org"
      }
    ]
  ],
  "verifyConditions": [
    "@semantic-release/changelog",
    "@semantic-release/git",
    "@semantic-release/gitlab",
    "@codedependant/semantic-release-docker"
  ],
  ...
}

or alternatively in YAML:

branch: master
preset: 'conventionalcommits'

plugins:
  - "@semantic-release/commit-analyzer"
  - "@semantic-release/release-notes-generator"
  - "@semantic-release/changelog"
  - "@semantic-release/git"
  - "@semantic-release/gitlab"
  - - '@codedependant/semantic-release-docker'
    - dockerTags:
        - latest
        - '{version}'
      dockerImage: sample-image
      dockerRegistry: registry.gitlab.com
      dockerProject: sample-org

verifyConditions:
  - '@semantic-release/changelog'
    # Verify the presence and the validity of the configuration
  - '@semantic-release/git'
    # Verify the presence and the validity of the Git authentication
    # and release configuration
  - '@semantic-release/gitlab'
    # Verify the presence and the validity of the GitLab authentication
    # and release configuration
  - '@codedependant/semantic-release-docker'
...

It appears to be failing because it does not pick up the dockerImage variable. The stack trace is as follows:

[12:25:57 PM] [semantic-release] › ✖  EINVAL Docker image name not found
Image name parsed from package.json name if possible. Or via the "image" option.
AggregateError: 
    SemanticReleaseError: Docker image name not found
        at verify (/usr/local/lib/node_modules/@codedependant/semantic-release-docker/lib/verify.js:17:19)
        at verifyConditions (/usr/local/lib/node_modules/@codedependant/semantic-release-docker/index.js:26:10)
        at async validator (/usr/local/lib/node_modules/semantic-release/lib/plugins/normalize.js:34:24)
        at async /usr/local/lib/node_modules/semantic-release/lib/plugins/pipeline.js:37:34
        at async /usr/local/lib/node_modules/semantic-release/lib/plugins/pipeline.js:31:3
        at async Object.pluginsConf.<computed> [as verifyConditions] (/usr/local/lib/node_modules/semantic-release/lib/plugins/index.js:80:11)
        at async run (/usr/local/lib/node_modules/semantic-release/index.js:95:3)
        at async module.exports (/usr/local/lib/node_modules/semantic-release/index.js:260:22)
        at async module.exports (/usr/local/lib/node_modules/semantic-release/cli.js:55:5)
    at /usr/local/lib/node_modules/semantic-release/lib/plugins/pipeline.js:54:11
    at async Object.pluginsConf.<computed> [as verifyConditions] (/usr/local/lib/node_modules/semantic-release/lib/plugins/index.js:80:11)
    at async run (/usr/local/lib/node_modules/semantic-release/index.js:95:3)
    at async module.exports (/usr/local/lib/node_modules/semantic-release/index.js:260:22)
    at async module.exports (/usr/local/lib/node_modules/semantic-release/cli.js:55:5)

I should note that passing the options at the top level (i.e. not at the plugin level) as follows does allow it to run:

branch: master
preset: 'conventionalcommits'

dockerTags:
  - latest
  - '{version}'
dockerImage: sample-image
dockerRegistry: registry.gitlab.com
dockerProject: sample-org

plugins:
  - "@semantic-release/commit-analyzer"
  - "@semantic-release/release-notes-generator"
  - "@semantic-release/changelog"
  - "@semantic-release/git"
  - "@semantic-release/gitlab"
  - "@codedependant/semantic-release-docker"


verifyConditions:
  - '@semantic-release/changelog'
    # Verify the presence and the validity of the configuration
  - '@semantic-release/git'
    # Verify the presence and the validity of the Git authentication
    # and release configuration
  - '@semantic-release/gitlab'
    # Verify the presence and the validity of the GitLab authentication
    # and release configuration
  - '@codedependant/semantic-release-docker'
@sashahilton00
Copy link
Author

As an addendum, it would be good if dockerImage, dockerRegistry and dockerProject could support templating, or otherwise be defined as environment variables, as this would enable one to avoid hard-coding values into the file as opposed to passing them at runtime.

@esatterwhite
Copy link
Owner

@sashahilton00, sorry I'm just getting around this. templating wouldn't be too hard to add at all.
I have found the way semantic release handles config merging frustrating. Can post the config that semantic release is actually picking up. You can set some debug environment variables to find it.

DEBUG=* DEBUG_DEPTH=100 DEBUG_HIDE_DATE=1 semantic-release

@esatterwhite esatterwhite added the bug Something isn't working label Sep 18, 2021
@sashahilton00
Copy link
Author

Sure, I’m travelling at the moment so probably won’t be able to test it again immediately, but will post when I get a chance.

@esatterwhite
Copy link
Owner

Additionally, which version of semantic-release are you using?

@esatterwhite
Copy link
Owner

As an addendum, it would be good if dockerImage, dockerRegistry and dockerProject could support templating, or otherwise be defined as environment variables, as this would enable one to avoid hard-coding values into the file as opposed to passing them at runtime.

If you are in a bind, I'm pretty sure the semantic-release cli lets you pass arbitrary options that get passed along.
I can't say that I've tried this, but I remember that being a thing.

semantic-release --dockerImage=foobar --dockerProject=${ENV_VAR}

@sashahilton00
Copy link
Author

Ok, so using the latest version of semantic release (18.0.0) with the following configuration:

---
branch: master
preset: 'conventionalcommits'

plugins:
  - "@semantic-release/commit-analyzer"
  - "@semantic-release/release-notes-generator"
  - "@semantic-release/changelog"
  - "@semantic-release/git"
  - "@semantic-release/gitlab"
  - "@semantic-release/exec"
  - path: "@codedependant/semantic-release-docker"
    dockerImage: 'redacted-repo'
    dockerRegistry: 'registry.gitlab.com'
    dockerProject: 'redacted-org'
    dockerTags:
      - latest
      - '{version}'

# Responsible for verifying conditions necessary to proceed with the release:
# configuration is correct, authentication token are valid, etc...
verifyConditions:
  - '@semantic-release/changelog'
    # Verify the presence and the validity of the configuration
  - '@semantic-release/git'
    # Verify the presence and the validity of the Git authentication
    # and release configuration
  - '@semantic-release/gitlab'
    # Verify the presence and the validity of the GitLab authentication
    # and release configuration
    # GITLAB_TOKEN must be defined in the CI and contain a personal access token with api and write_repository access.
  - '@codedependant/semantic-release-docker'

# Responsible for determining the type of the next release (major, minor or patch).
# If multiple plugins with a analyzeCommits step are defined, the release type will be
# the highest one among plugins output.
# Look details at: https://github.com/semantic-release/commit-analyzer#configuration
analyzeCommits:
  - path: "@semantic-release/commit-analyzer"
    releaseRules:
      - breaking: true
        release: major
      - type: build     # Changes that affect the build system or external dependencies
                        # (example scopes: gulp, broccoli, npm)
        release: patch
      - type: chore     # Other changes that don't modify src or test files
        release: false
      - type: ci        # Changes to our CI configuration files and scripts
        release: false
      - type: docs      # Documentation only changes
        release: patch
      - type: feat      # A new feature
        release: minor
      - type: fix       # A bug fix
        release: patch
      - type: perf      # A code change that improves performance
        release: patch
      - type: refactor  # A code change that neither fixes a bug nor adds a feature
        release: false
      - type: revert    # Reverts a previous commit
        release: patch
      - type: style     # Changes that do not affect the meaning of the code
                        # (white-space, formatting, missing semi-colons, etc)
        release: false
      - type: test      # Adding missing tests or correcting existing tests
        release: false

# Responsible for generating the content of the release note.
# If multiple plugins with a generateNotes step are defined,
# the release notes will be the result of the concatenation of each plugin output.
generateNotes:
  - path: "@semantic-release/release-notes-generator"
    writerOpts:
      groupBy: "type"
      commitGroupsSort:
        - "feat"
        - "fix"
        - "perf"
        - "docs"
      commitsSort: "header"
    linkCompare: true
    linkReferences: true
    presetConfig:
      types:
        - type: 'build'
          section: '🦊 CI/CD'
          hidden: true
        - type: 'chore'
          section: 'Other'
          hidden: true
        - type: 'ci'
          section: '🦊 CI/CD'
          hidden: true
        - type: 'docs'
          section: '📔 Docs'
          hidden: false
        - type: 'example'
          section: '📝 Examples'
          hidden: false
        - type: 'feat'
          section: '🚀 Features'
          hidden: false
        - type: 'fix'
          section: '🛠 Fixes'
          hidden: false
        - type: 'perf'
          section: '⏩ Performance'
        - type: 'refactor'
          section: ':scissors: Refactor'
          hidden: true
        - type: 'revert'
          section: '🙅‍️ Reverts'
        - type: 'style'
          section: '💈 Style'
          hidden: true
        - type: 'test'
          section: '🧪 Tests'
          hidden: true

# Responsible for preparing the release, for example creating or updating files
# such as package.json, CHANGELOG.md, documentation or compiled assets
# and pushing a commit.
prepare:
  - path: "@semantic-release/changelog"
    changelogFile: "CHANGELOG.md"
  # Create or update the changelog file in the local project repository
  - path: "@semantic-release/git"
    message: 'chore(release): release ${nextRelease.version}'
    assets:
      - "CHANGELOG.md"
  # Push a release commit and tag, including configurable files
  - path: "@codedependant/semantic-release-docker"
  # Build docker image from Dockerfile.

# Responsible for publishing the release.
publish:
  - path: '@semantic-release/gitlab'
  # Publish a GitLab release
  #  (https://docs.gitlab.com/ce/user/project/releases/index.html#add-release-notes-to-git-tags)
  - path: "@semantic-release/exec"
    cmd: 'sentry-cli releases new ${nextRelease.version}'
  # Prepare release on sentry.io
  # This requires the SENTRY_AUTH_TOKEN, SENTRY_ORG and SENTRY_PROJECT env variables to be set.
  # The first 1/2 are set at a group level. The latter variable(s) is set at a project level.
  - path: "@semantic-release/exec"
    cmd: 'sentry-cli releases set-commits ${nextRelease.version} --auto'
  # Auto detect commits that form the release
  - path: "@codedependant/semantic-release-docker"
  # Tag and upload docker image to registry.
  - path: "@semantic-release/exec"
    cmd: 'sentry-cli releases finalize ${nextRelease.version}'
  # Finalise release on sentry.io

Results in:

...
[4:03:12 PM] [semantic-release] › ✔  Loaded plugin "analyzeCommits" from "@semantic-release/commit-analyzer"
semantic-release:plugins options for @semantic-release/exec/verifyRelease: {}
[4:03:12 PM] [semantic-release] › ✔  Loaded plugin "verifyRelease" from "@semantic-release/exec"
semantic-release:plugins options for @semantic-release/release-notes-generator/generateNotes: {
  writerOpts: {
    groupBy: 'type',
    commitGroupsSort: [ 'feat', 'fix', 'perf', 'docs' ],
    commitsSort: 'header'
  },
  linkCompare: true,
  linkReferences: true,
  presetConfig: {
    types: [
      { type: 'build', section: '🦊 CI/CD', hidden: true },
      { type: 'chore', section: 'Other', hidden: true },
      { type: 'ci', section: '🦊 CI/CD', hidden: true },
      { type: 'docs', section: '📔 Docs', hidden: false },
      { type: 'example', section: '📝 Examples', hidden: false },
      { type: 'feat', section: '🚀 Features', hidden: false },
      { type: 'fix', section: '🛠 Fixes', hidden: false },
      { type: 'perf', section: '⏩ Performance' },
      {
        type: 'refactor',
        section: ':scissors: Refactor',
        hidden: true
      },
      { type: 'revert', section: '🙅‍️ Reverts' },
      { type: 'style', section: '💈 Style', hidden: true },
      { type: 'test', section: '🧪 Tests', hidden: true }
    ]
  }
}
[4:03:12 PM] [semantic-release] › ✔  Loaded plugin "generateNotes" from "@semantic-release/release-notes-generator"
semantic-release:plugins options for @semantic-release/changelog/prepare: { changelogFile: 'CHANGELOG.md' }
[4:03:12 PM] [semantic-release] › ✔  Loaded plugin "prepare" from "@semantic-release/changelog"
semantic-release:plugins options for @semantic-release/git/prepare: {
  message: 'chore(release): release ${nextRelease.version}',
  assets: [ 'CHANGELOG.md' ]
}
[4:03:12 PM] [semantic-release] › ✔  Loaded plugin "prepare" from "@semantic-release/git"
semantic-release:plugins options for @codedependant/semantic-release-docker/prepare: {}
[4:03:12 PM] [semantic-release] › ✔  Loaded plugin "prepare" from "@codedependant/semantic-release-docker"
semantic-release:plugins options for @semantic-release/gitlab/publish: {}
[4:03:12 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/gitlab"
semantic-release:plugins options for @semantic-release/exec/publish: { cmd: 'sentry-cli releases new ${nextRelease.version}' }
[4:03:12 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/exec"
semantic-release:plugins options for @semantic-release/exec/publish: {
  cmd: 'sentry-cli releases set-commits ${nextRelease.version} --auto'
}
[4:03:12 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/exec"
semantic-release:plugins options for @codedependant/semantic-release-docker/publish: {}
[4:03:12 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@codedependant/semantic-release-docker"
semantic-release:plugins options for @semantic-release/exec/publish: { cmd: 'sentry-cli releases finalize ${nextRelease.version}' }
[4:03:12 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/exec"
semantic-release:plugins options for @semantic-release/exec/addChannel: {}
[4:03:12 PM] [semantic-release] › ✔  Loaded plugin "addChannel" from "@semantic-release/exec"
semantic-release:plugins options for @semantic-release/exec/success: {}
[4:03:12 PM] [semantic-release] › ✔  Loaded plugin "success" from "@semantic-release/exec"
semantic-release:plugins options for @semantic-release/exec/fail: {}
[4:03:12 PM] [semantic-release] › ✔  Loaded plugin "fail" from "@semantic-release/exec"
semantic-release:get-git-auth-url Verifying ssh auth by attempting to push to  https://gitlab-ci-token:[secure]@gitlab.com/[MASKED]/redacted-repo.git
semantic-release:git Error: Command failed with exit code 128: git push --dry-run --no-verify https://gitlab-ci-token:[secure]@gitlab.com/[MASKED]/redacted-repo.git HEAD:master
remote: You are not allowed to upload code.
fatal: unable to access 'https://gitlab.com/[MASKED]/redacted-repo.git/': The requested URL returned error: 403
    at makeError (/usr/local/lib/node_modules/semantic-release/node_modules/execa/lib/error.js:60:11)
    at handlePromise (/usr/local/lib/node_modules/semantic-release/node_modules/execa/index.js:118:26)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async verifyAuth (/usr/local/lib/node_modules/semantic-release/lib/git.js:207:5)
    at async module.exports (/usr/local/lib/node_modules/semantic-release/lib/get-git-auth-url.js:91:5)
    at async run (/usr/local/lib/node_modules/semantic-release/index.js:56:27)
    at async module.exports (/usr/local/lib/node_modules/semantic-release/index.js:260:22)
    at async module.exports (/usr/local/lib/node_modules/semantic-release/cli.js:55:5)
semantic-release:get-git-auth-url SSH key auth failed, falling back to https.
semantic-release:get-tags found tags for branch master: [ { gitTag: 'v1.0.0', version: '1.0.0', channels: [ null ] }, { gitTag: 'v1.0.1', version: '1.0.1', channels: [ null ] }, { gitTag: 'v1.0.2', version: '1.0.2', channels: [ null ] }, { gitTag: 'v1.0.3', version: '1.0.3', channels: [ null ] }, { gitTag: 'v1.0.4', version: '1.0.4', channels: [ null ] }, { gitTag: 'v1.0.5', version: '1.0.5', channels: [ null ] }, { gitTag: 'v1.1.0', version: '1.1.0', channels: [ null ] }, { gitTag: 'v1.1.1', version: '1.1.1', channels: [ null ] }, { gitTag: 'v1.2.0', version: '1.2.0', channels: [ null ] }, { gitTag: 'v1.2.1', version: '1.2.1', channels: [ null ] } ]
[4:03:15 PM] [semantic-release] › ✔  Run automated release from branch master on repository https://gitlab-ci-token:[secure]@gitlab.com/[MASKED]/redacted-repo.git
[4:03:15 PM] [semantic-release] › ✔  Allowed to push to the Git repository
[4:03:15 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/changelog"
[4:03:15 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/changelog"
[4:03:15 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/git"
[4:03:15 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/git"
[4:03:15 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/gitlab"
semantic-release:gitlab apiUrl: 'https://gitlab.com/api/v4'
semantic-release:gitlab repoId: '[MASKED]/redacted-repo'
[4:03:15 PM] [semantic-release] [@semantic-release/gitlab] › ℹ  Verify GitLab authentication (https://gitlab.com/api/v4)
[4:03:16 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/gitlab"
[4:03:16 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@codedependant/semantic-release-docker"
[4:03:16 PM] [semantic-release] › ✖  Failed step "verifyConditions" of plugin "@codedependant/semantic-release-docker"
[4:03:16 PM] [semantic-release] › ℹ  Start step "fail" of plugin "@semantic-release/exec"
[4:03:16 PM] [semantic-release] › ✔  Completed step "fail" of plugin "@semantic-release/exec"
[4:03:16 PM] [semantic-release] › ✖  EINVAL Docker image name not found
Image name parsed from package.json name if possible. Or via the "dockerImage" option.

AggregateError: 
    SemanticReleaseError: Docker image name not found
        at verify (/usr/local/lib/node_modules/@codedependant/semantic-release-docker/lib/verify.js:17:19)
        at verifyConditions (/usr/local/lib/node_modules/@codedependant/semantic-release-docker/index.js:26:10)
        at async validator (/usr/local/lib/node_modules/semantic-release/lib/plugins/normalize.js:34:24)
        at async /usr/local/lib/node_modules/semantic-release/lib/plugins/pipeline.js:37:34
        at async /usr/local/lib/node_modules/semantic-release/lib/plugins/pipeline.js:31:3
        at async Object.pluginsConf.<computed> [as verifyConditions] (/usr/local/lib/node_modules/semantic-release/lib/plugins/index.js:80:11)
        at async run (/usr/local/lib/node_modules/semantic-release/index.js:95:3)
        at async module.exports (/usr/local/lib/node_modules/semantic-release/index.js:260:22)
        at async module.exports (/usr/local/lib/node_modules/semantic-release/cli.js:55:5)
    at /usr/local/lib/node_modules/�[4msemantic-release�[24m/lib/plugins/pipeline.js:54:11
    at async Object.pluginsConf.<computed> [as verifyConditions] (/usr/local/lib/node_modules/�[4msemantic-release�[24m/lib/plugins/index.js:80:11)
    at async run (/usr/local/lib/node_modules/�[4msemantic-release�[24m/index.js:95:3)
    at async module.exports (/usr/local/lib/node_modules/�[4msemantic-release�[24m/index.js:260:22)
    at async module.exports (/usr/local/lib/node_modules/�[4msemantic-release�[24m/cli.js:55:5)section_end:1634140999:step_script
�[0Ksection_start:1634140999:cleanup_file_variables
�[0K�[0K�[36;1mCleaning up project directory and file based variables�[0;m�[0;m
section_end:1634140999:cleanup_file_variables
�[0K�[31;1mERROR: Job failed: exit code 1
�[0;m

However, when moving plugin configuration to the prepare section as follows:

---
branch: master
preset: 'conventionalcommits'

plugins:
  - "@semantic-release/commit-analyzer"
  - "@semantic-release/release-notes-generator"
  - "@semantic-release/changelog"
  - "@semantic-release/git"
  - "@semantic-release/gitlab"
  - "@semantic-release/exec"
  - "@codedependant/semantic-release-docker"

# Responsible for verifying conditions necessary to proceed with the release:
# configuration is correct, authentication token are valid, etc...
verifyConditions:
  - '@semantic-release/changelog'
    # Verify the presence and the validity of the configuration
  - '@semantic-release/git'
    # Verify the presence and the validity of the Git authentication
    # and release configuration
  - '@semantic-release/gitlab'
    # Verify the presence and the validity of the GitLab authentication
    # and release configuration
    # GITLAB_TOKEN must be defined in the CI and contain a personal access token with api and write_repository access.
  - '@codedependant/semantic-release-docker'

# Responsible for determining the type of the next release (major, minor or patch).
# If multiple plugins with a analyzeCommits step are defined, the release type will be
# the highest one among plugins output.
# Look details at: https://github.com/semantic-release/commit-analyzer#configuration
analyzeCommits:
  - path: "@semantic-release/commit-analyzer"
    releaseRules:
      - breaking: true
        release: major
      - type: build     # Changes that affect the build system or external dependencies
                        # (example scopes: gulp, broccoli, npm)
        release: patch
      - type: chore     # Other changes that don't modify src or test files
        release: false
      - type: ci        # Changes to our CI configuration files and scripts
        release: false
      - type: docs      # Documentation only changes
        release: patch
      - type: feat      # A new feature
        release: minor
      - type: fix       # A bug fix
        release: patch
      - type: perf      # A code change that improves performance
        release: patch
      - type: refactor  # A code change that neither fixes a bug nor adds a feature
        release: false
      - type: revert    # Reverts a previous commit
        release: patch
      - type: style     # Changes that do not affect the meaning of the code
                        # (white-space, formatting, missing semi-colons, etc)
        release: false
      - type: test      # Adding missing tests or correcting existing tests
        release: false

# Responsible for generating the content of the release note.
# If multiple plugins with a generateNotes step are defined,
# the release notes will be the result of the concatenation of each plugin output.
generateNotes:
  - path: "@semantic-release/release-notes-generator"
    writerOpts:
      groupBy: "type"
      commitGroupsSort:
        - "feat"
        - "fix"
        - "perf"
        - "docs"
      commitsSort: "header"
    linkCompare: true
    linkReferences: true
    presetConfig:
      types:
        - type: 'build'
          section: '🦊 CI/CD'
          hidden: true
        - type: 'chore'
          section: 'Other'
          hidden: true
        - type: 'ci'
          section: '🦊 CI/CD'
          hidden: true
        - type: 'docs'
          section: '📔 Docs'
          hidden: false
        - type: 'example'
          section: '📝 Examples'
          hidden: false
        - type: 'feat'
          section: '🚀 Features'
          hidden: false
        - type: 'fix'
          section: '🛠 Fixes'
          hidden: false
        - type: 'perf'
          section: '⏩ Performance'
        - type: 'refactor'
          section: ':scissors: Refactor'
          hidden: true
        - type: 'revert'
          section: '🙅‍️ Reverts'
        - type: 'style'
          section: '💈 Style'
          hidden: true
        - type: 'test'
          section: '🧪 Tests'
          hidden: true

# Responsible for preparing the release, for example creating or updating files
# such as package.json, CHANGELOG.md, documentation or compiled assets
# and pushing a commit.
prepare:
  - path: "@semantic-release/changelog"
    changelogFile: "CHANGELOG.md"
  # Create or update the changelog file in the local project repository
  - path: "@semantic-release/git"
    message: 'chore(release): release ${nextRelease.version}'
    assets:
      - "CHANGELOG.md"
  # Push a release commit and tag, including configurable files
  - path: "@codedependant/semantic-release-docker"
    dockerImage: 'redacted-repo'
    dockerRegistry: 'registry.gitlab.com'
    dockerProject: 'redacted-org'
    dockerTags:
      - latest
      - '{version}'
  # Build docker image from Dockerfile.

# Responsible for publishing the release.
publish:
  - path: '@semantic-release/gitlab'
  # Publish a GitLab release
  #  (https://docs.gitlab.com/ce/user/project/releases/index.html#add-release-notes-to-git-tags)
  - path: "@semantic-release/exec"
    cmd: 'sentry-cli releases new ${nextRelease.version}'
  # Prepare release on sentry.io
  # This requires the SENTRY_AUTH_TOKEN, SENTRY_ORG and SENTRY_PROJECT env variables to be set.
  # The first 1/2 are set at a group level. The latter variable(s) is set at a project level.
  - path: "@semantic-release/exec"
    cmd: 'sentry-cli releases set-commits ${nextRelease.version} --auto'
  # Auto detect commits that form the release
  - path: "@codedependant/semantic-release-docker"
  # Tag and upload docker image to registry.
  - path: "@semantic-release/exec"
    cmd: 'sentry-cli releases finalize ${nextRelease.version}'
  # Finalise release on sentry.io

The following is logged:

...
[4:10:03 PM] [semantic-release] › ✔  Loaded plugin "generateNotes" from "@semantic-release/release-notes-generator"
semantic-release:plugins options for @semantic-release/changelog/prepare: { changelogFile: 'CHANGELOG.md' }
[4:10:03 PM] [semantic-release] › ✔  Loaded plugin "prepare" from "@semantic-release/changelog"
semantic-release:plugins options for @semantic-release/git/prepare: {
  message: 'chore(release): release ${nextRelease.version}',
  assets: [ 'CHANGELOG.md' ]
}
[4:10:03 PM] [semantic-release] › ✔  Loaded plugin "prepare" from "@semantic-release/git"
semantic-release:plugins options for @codedependant/semantic-release-docker/prepare: {
  dockerImage: 'redacted-repo',
  dockerRegistry: 'registry.gitlab.com',
  dockerProject: '[MASKED]',
  dockerTags: [ 'latest', '{version}' ]
}
[4:10:03 PM] [semantic-release] › ✔  Loaded plugin "prepare" from "@codedependant/semantic-release-docker"
semantic-release:plugins options for @semantic-release/gitlab/publish: {}
[4:10:03 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/gitlab"
semantic-release:plugins options for @semantic-release/exec/publish: { cmd: 'sentry-cli releases new ${nextRelease.version}' }
[4:10:03 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/exec"
semantic-release:plugins options for @semantic-release/exec/publish: {
  cmd: 'sentry-cli releases set-commits ${nextRelease.version} --auto'
}
[4:10:03 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/exec"
semantic-release:plugins options for @codedependant/semantic-release-docker/publish: {}
[4:10:03 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@codedependant/semantic-release-docker"
semantic-release:plugins options for @semantic-release/exec/publish: { cmd: 'sentry-cli releases finalize ${nextRelease.version}' }
[4:10:03 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/exec"
semantic-release:plugins options for @semantic-release/exec/addChannel: {}
[4:10:03 PM] [semantic-release] › ✔  Loaded plugin "addChannel" from "@semantic-release/exec"
semantic-release:plugins options for @semantic-release/exec/success: {}
[4:10:03 PM] [semantic-release] › ✔  Loaded plugin "success" from "@semantic-release/exec"
semantic-release:plugins options for @semantic-release/exec/fail: {}
[4:10:03 PM] [semantic-release] › ✔  Loaded plugin "fail" from "@semantic-release/exec"
semantic-release:get-git-auth-url Verifying ssh auth by attempting to push to  https://gitlab-ci-token:[secure]@gitlab.com/[MASKED]/redacted-repo.git
semantic-release:git Error: Command failed with exit code 128: git push --dry-run --no-verify https://gitlab-ci-token:[secure]@gitlab.com/[MASKED]/redacted-repo.git HEAD:master
remote: You are not allowed to upload code.
fatal: unable to access 'https://gitlab.com/[MASKED]/redacted-repo.git/': The requested URL returned error: 403
    at makeError (/usr/local/lib/node_modules/semantic-release/node_modules/execa/lib/error.js:60:11)
    at handlePromise (/usr/local/lib/node_modules/semantic-release/node_modules/execa/index.js:118:26)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async verifyAuth (/usr/local/lib/node_modules/semantic-release/lib/git.js:207:5)
    at async module.exports (/usr/local/lib/node_modules/semantic-release/lib/get-git-auth-url.js:91:5)
    at async run (/usr/local/lib/node_modules/semantic-release/index.js:56:27)
    at async module.exports (/usr/local/lib/node_modules/semantic-release/index.js:260:22)
    at async module.exports (/usr/local/lib/node_modules/semantic-release/cli.js:55:5)
semantic-release:get-git-auth-url SSH key auth failed, falling back to https.
semantic-release:get-tags found tags for branch master: [ { gitTag: 'v1.0.0', version: '1.0.0', channels: [ null ] }, { gitTag: 'v1.0.1', version: '1.0.1', channels: [ null ] }, { gitTag: 'v1.0.2', version: '1.0.2', channels: [ null ] }, { gitTag: 'v1.0.3', version: '1.0.3', channels: [ null ] }, { gitTag: 'v1.0.4', version: '1.0.4', channels: [ null ] }, { gitTag: 'v1.0.5', version: '1.0.5', channels: [ null ] }, { gitTag: 'v1.1.0', version: '1.1.0', channels: [ null ] }, { gitTag: 'v1.1.1', version: '1.1.1', channels: [ null ] }, { gitTag: 'v1.2.0', version: '1.2.0', channels: [ null ] }, { gitTag: 'v1.2.1', version: '1.2.1', channels: [ null ] } ]
[4:10:06 PM] [semantic-release] › ✔  Run automated release from branch master on repository https://gitlab-ci-token:[secure]@gitlab.com/[MASKED]/redacted-repo.git
[4:10:06 PM] [semantic-release] › ✔  Allowed to push to the Git repository
[4:10:06 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/changelog"
[4:10:06 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/changelog"
[4:10:06 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/git"
[4:10:06 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/git"
[4:10:06 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/gitlab"
semantic-release:gitlab apiUrl: 'https://gitlab.com/api/v4'
semantic-release:gitlab repoId: '[MASKED]/redacted-repo'
[4:10:06 PM] [semantic-release] [@semantic-release/gitlab] › ℹ  Verify GitLab authentication (https://gitlab.com/api/v4)
[4:10:06 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/gitlab"
[4:10:06 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@codedependant/semantic-release-docker"
[4:10:06 PM] [semantic-release] › ✖  Failed step "verifyConditions" of plugin "@codedependant/semantic-release-docker"
[4:10:06 PM] [semantic-release] › ℹ  Start step "fail" of plugin "@semantic-release/exec"
[4:10:06 PM] [semantic-release] › ✔  Completed step "fail" of plugin "@semantic-release/exec"
[4:10:06 PM] [semantic-release] › ✖  EINVAL Docker image name not found
Image name parsed from package.json name if possible. Or via the "dockerImage" option.

AggregateError: 
    SemanticReleaseError: Docker image name not found
        at verify (/usr/local/lib/node_modules/@codedependant/semantic-release-docker/lib/verify.js:17:19)
        at verifyConditions (/usr/local/lib/node_modules/@codedependant/semantic-release-docker/index.js:26:10)
        at async validator (/usr/local/lib/node_modules/semantic-release/lib/plugins/normalize.js:34:24)
        at async /usr/local/lib/node_modules/semantic-release/lib/plugins/pipeline.js:37:34
        at async /usr/local/lib/node_modules/semantic-release/lib/plugins/pipeline.js:31:3
        at async Object.pluginsConf.<computed> [as verifyConditions] (/usr/local/lib/node_modules/semantic-release/lib/plugins/index.js:80:11)
        at async run (/usr/local/lib/node_modules/semantic-release/index.js:95:3)
        at async module.exports (/usr/local/lib/node_modules/semantic-release/index.js:260:22)
        at async module.exports (/usr/local/lib/node_modules/semantic-release/cli.js:55:5)
    at /usr/local/lib/node_modules/�[4msemantic-release�[24m/lib/plugins/pipeline.js:54:11
    at async Object.pluginsConf.<computed> [as verifyConditions] (/usr/local/lib/node_modules/�[4msemantic-release�[24m/lib/plugins/index.js:80:11)
    at async run (/usr/local/lib/node_modules/�[4msemantic-release�[24m/index.js:95:3)
    at async module.exports (/usr/local/lib/node_modules/�[4msemantic-release�[24m/index.js:260:22)
    at async module.exports (/usr/local/lib/node_modules/�[4msemantic-release�[24m/cli.js:55:5)section_end:1634141409:step_script
�[0Ksection_start:1634141409:cleanup_file_variables
�[0K�[0K�[36;1mCleaning up project directory and file based variables�[0;m�[0;m
section_end:1634141410:cleanup_file_variables
�[0K�[31;1mERROR: Job failed: exit code 1
�[0;m

As you can see, the plugin picks up the configuration for the prepare, then still proceeds to throw a SemanticReleaseError at the release step, which is expected as the dockerImage variable is not specified. What this doesn't explain though is why when using the exact same syntax and passing the configuration to the plugin at the top level, none of the steps that follow pick up the config.

@esatterwhite
Copy link
Owner

esatterwhite commented Oct 18, 2021

@sashahilton00 Thanks for the detailed report. This gives me a lot to go on. In all honesty, I wasn't aware that you could configure specific steps like this

  "verifyConditions": [
    "@semantic-release/changelog",
    "@semantic-release/git",
    "@semantic-release/gitlab",
    "@codedependant/semantic-release-docker"
  ]

If all of the steps use the same plugins, I generally don't think you need to do that and would probably lead to some of the behaviors you are seeing. I would have just specified the globals and omitted the step specific configs.

{
  "branch": "master",
  "preset": "conventionalcommits",
  "dockerTags": [
     "latest",
     "{version}"
   ],
  "dockerImage": "sample-image",
  "dockerRegistry": "registry.gitlab.com",
  "dockerProject": "sample-org",
  "writerOpts": {
      "commitsSort": "header",
      "groupBy": "type",
      "commitGroupsSort": [
        "feat",
        "fix",
        "perf",
        "docs",
       ],
    "releaseRules": [
      {"breaking": true, "release": "major"},
      ...
    ]
  },
  "plugins": [
    "@semantic-release/commit-analyzer",
    ["@semantic-release/release-notes-generator", {...}]
    "@semantic-release/changelog",
    "@semantic-release/git",
    ["@semantic-release/gitlab", {...}]
    "@codedependant/semantic-release-docker",
  ]
}

This is probably a result of the way plugin config is handled via semantic release, and in transparency, not something I really took into account. I would bet the plugin is being re-instantiated at each step and the global config may not be passed from semantic-release. Not sure.

I'll look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants