PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label bitbucket. Show all posts
Showing posts with label bitbucket. Show all posts

Thursday, November 17, 2022

[FIXED] How to prevent Markdown's list from eating spaces?

 November 17, 2022     bitbucket, list, markdown, readme, vertical-alignment     No comments   

Issue

I have:

- `foo`: some text                       Default: false
- `barThatIsTooLong`: again some text    Default: true

but in Bitbucket README, whitespaces will be eaten automatically, and this will be displayed as:

  • foo: some text Default: false
  • barThatIsTooLong: again some text Default: true

I would like to have the default values vertically aligned.

How to tell Bitbucket's markdown to not eat my spaces? Is it even possible?


Solution

You probably can't, unless you use tables instead of lists.

| Variable           | Description     | Default |
| -------------------|---------------- | ------- |
| `foo`              | some text       | false   |
| `barThatIsTooLong` | again some text | true    |

If you are using a site which doesn't strip out raw HTML and/or style attributes, then inline floats might work:

- `foo`: some text                    <span style="float:right; width:10em;">Default: false</span>
- `barThatIsTooLong`: again some text <span style="float:right; width:10em;">Default: true</span>

The long answer

Collapsing whitespace is a "feature" of HTML, of which Markdown is a subset. The "feature" is often referred to as "insignificant whitespace." The idea is that all whitespace (spaces, tabs, newlines, etc.) is collapsed into a single space (see a summary of whitespace behavior options). Note that this collapse of whitespace is being done by your browser, not the Markdown parser. If you use your browser's "view source" of "inspect" feature, you will see that the HTML list retains the whitespace:

<ul>
<li><code>foo</code>: some text                       Default: false</li>
<li><code>barThatIsTooLong</code>: again some text    Default: true</li>
</ul>

In other words, Markdown is not eating your whitespace, your browser is. So the next question is how to preserve whitespace in HTML and how that can be incorporated into your Markdown. There are a number of different ways to do that, but, in the end, they will not work as you desire.

  1. The <pre> tag preserves whitespace, but is a block-level tag and not for inline use. As you only want some inline whitespace, preserved, not the entire block of text, this is not useful.

  2. The whitespace:pre CSS rule could be used to get that effect, but will look ugly in your Markdown. Also, Bitbucket may strip your style tags for security reasons (SO does).

    - `foo`: some text<span style="white-space:pre">                       </span>Default: false
    - `barThatIsTooLong`: again some text<span style="white-space:pre">    </span>Default: true
    
  3. As non-breaking spaces are not collapsed, you could use them rather than regular spaces. In fact, you only need every other space to be a non-breaking space. But, again, it is ugly. Even worse, as non-breaking spaces are entered as HTML entities, one displayed character is 6 characters long in your Markdown, so the columns don't line up properly in the source document.

    - `foo`: some text &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Default: false
    - `barThatIsTooLong`: again some text &nbsp; &nbsp;Default: true
    

But even if you get one of the above to work, the browser probably still won't display your list as you desire. Bitbucket, like most websites do not use monospace fonts for their website (except in code blocks). Therefore, the width of each letter in a line is not equal and your columns still won't line up. Notice that the same situation exists here on SO. The last example above renders like this:

  • foo: some text                       Default: false
  • barThatIsTooLong: again some text    Default: true

You can see the same effect in your editor. If you change the font from a monospace font to a proportional font you will notice that the columns will misalign. And that misalignment will vary with each different proportional font. Therefore, simply adjusting the number of spaces won't guarantee proper alignment. You may even end up with a half-width misalignment.

Of course, websites have columns all the time. But those columns are not "faked" with inline text. Each column is wrapped in its own block-level element and CSS rules position and size the containing box appropriately as demonstrated in this answer. But again, that requires raw HTML and CSS which Bitbucket is likely to not allow for security reasons.

One other option might be to use inline floats:

- `foo`: some text                    <span style="float:right; width:10em;">Default: false</span>
- `barThatIsTooLong`: again some text <span style="float:right; width:10em;">Default: true</span>

This causes the <span> to be floated to the far right edge of the containing block (the list item). To avoid the floated items appearing right aligned, we have included the width which ensures that each <span> is the same width. The actual width needs to be at least as wide as the largest text within the span. However, there is still the fact that Bitbucket will likely strip out the raw HTML for security reasons.

However, Bitbucket's Markdown implementation does support simple tables. So if you really want columns, you could implement them as tables. Of course, you would need to have table rows rather than list items in addition to column headers, which you may or may not want.

| Variable           | Description     | Default |
| -------------------|---------------- | ------- |
| `foo`              | some text       | false   |
| `barThatIsTooLong` | again some text | true    |


Answered By - Waylan
Answer Checked By - Marilyn (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Sunday, November 13, 2022

[FIXED] How to invoke Plesk Git extension webhook via cURL from Bitbucket Pipelines?

 November 13, 2022     bitbucket, bitbucket-pipelines, git, plesk     No comments   

Issue

Unfortunately, Bitbucket doesn't support per-branch webhooks and won't support them in the near future (https://bitbucket.org/site/master/issues/11728/trigger-webhook-only-for-push-to-specific).

So I thought I maybe could write a simple bitbucket-pipelines.yml which calls the corresponding webhook:

pipelines:
  branches:
    staging:
      - step:
          script:
            - curl $WEBHOOK_STAGING
    master:
      - step:
          script:
            - curl $WEBHOOK_PRODUCTION

Simply requesting the webhook, doesn't seem to trigger a git pull within Plesk, so I'm assuming that I need to add a payload.

Question: What do I need to send to the Plesk webhook in order to perform a pull?


Solution

Webhooks are done via a POST request instead of a GET request, so you will have to pass the argument -X POST to curl in order to send the request to your webhook correctly.

So your curl statement would look like this:

curl -X POST $WEBHOOK_PRODUCTION


Answered By - Sven Hakvoort
Answer Checked By - Marilyn (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Tuesday, September 27, 2022

[FIXED] How to commit only a specific directory to a remote branch? (deleting all other content)

 September 27, 2022     bitbucket, continuous-deployment, deployment, git, plesk     No comments   

Issue

I have a branch named deployment and I want to push only the contents of the folder dist to this branch in my remote repository, deleting all other content.

I have tried so far

  • Flag git push with --prefix
  • cd dist and git push

Observations

  1. A warning that says it is already up-to-date
  2. Remote has everything in there (and not just the 'dist' folder)

How do I select only dist/ folder in my commit?


Solution

As I understand, you want to

Commit only a specific directory to a remote branch (deleting all other content)

Since deployment is created (branched out) from a branch that has all the files, you will need to delete unwanted files in the deployment branch. You can get to the desired state with the following steps:

  1. Pull the latest changes: git reset --hard HEAD; git fetch
  2. Go to your branch: git checkout deployment
  3. Delete unwanted files/directories (other than dist/): find * -maxdepth 0 -name 'dist' -prune -o -exec rm -rf '{}' ';'
  4. Stage deleted changes: git add .
  5. Commit & push to remote: git commit -m "Commit message"; git push origin deployment

Hope it helps!



Answered By - nkshio
Answer Checked By - Terry (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to pass the correct project path to bitbucket pipeline?

 September 27, 2022     amazon-web-services, aws-lambda, bitbucket, bitbucket-pipelines, continuous-deployment     No comments   

Issue

I want to deploy aws lamda .net core project using bit bucket pipeline

I have created bitbucket-pipelines.yml like below but after build run getting error -

MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.

file code -

image: microsoft/dotnet:sdk

pipelines:
  default:
    - step:
        caches:
          - dotnetcore
        script: # Modify the commands below to build your repository.
          - export PROJECT_NAME=TestAWS/AWSLambda1/AWSLambda1.sln
          - dotnet restore
          - dotnet build $PROJECT_NAME
          - pipe: atlassian/aws-lambda-deploy:0.2.1
            variables:
              AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
              AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
              AWS_DEFAULT_REGION: 'us-east-1'
              FUNCTION_NAME: 'my-lambda-function'
              COMMAND: 'update'
              ZIP_FILE: 'code.zip'

project structure is like this -

enter image description here


Solution

The problem is here:

PROJECT_NAME=TestAWS/AWSLambda1/AWSLambda1.sln

This is the incorrect path. Bitbucket Pipelines will use a special path in the Docker image, something like /opt/atlassian/pipelines/agent/build/YOUR_PROJECT , to do a Git clone of your project.

You can see this when you click on the "Build Setup" step in the Pipelines web console:

Cloning into '/opt/atlassian/pipelines/agent/build'...

You can use a pre-defined environment variable to retrieve this path: $BITBUCKET_CLONE_DIR , as described here: https://support.atlassian.com/bitbucket-cloud/docs/variables-in-pipelines/

Consider something like this in your yml build script:

script:
  - echo $BITBUCKET_CLONE_DIR # Debug: Print the $BITBUCKET_CLONE_DIR
  - pwd # Debug: Print the current working directory
  - find "$(pwd -P)" -name AWSLambda1.sln # Debug: Show the full file path of AWSLambda1.sln

  - export PROJECT_NAME="$BITBUCKET_CLONE_DIR/AWSLambda1.sln"
  - echo $PROJECT_NAME
  - if [ -f "$PROJECT_NAME" ]; then echo "File exists" ; fi

  # Try this if the file path is not as expected
  - export PROJECT_NAME="$BITBUCKET_CLONE_DIR/AWSLambda1/AWSLambda1.sln"
  - echo $PROJECT_NAME
  - if [ -f "$PROJECT_NAME" ]; then echo "File exists" ; fi


Answered By - Mr-IDE
Answer Checked By - David Marino (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Wednesday, September 14, 2022

[FIXED] How do I remove the .exec extension git applies to files?

 September 14, 2022     bitbucket, exec, git, ios, pull-request     No comments   

Issue

I messed up so I downloaded an old commit and tried to build from some old code that functioned as intended. I see the files (Podfile, License Gemfile etc) now have a .exec extension and when I push to bitBucket they have a "+x" annotation. When you hover over it says this file is now executable.

Everything still happens to build and run successfully but why does git add this extension to my files without my say so? This issue is causing some concern on my pull request. How do I return my files to being just plainText or whatever they were originally?

I've tried to run chmod -x $(find . -type exec) in the offending directory but this doesn't seem to work.

Anyone know how restore my file to their former purity???


Solution

You could:

  • rename your files
  • add them again, explicitely removing the 'x' executable bit with git add --chmod=-x aFile

Then you can commit and push again.


But make sure to use Git 2.31 (Q1 2021), because of various fixes on "git add --chmod"(man)".

See commit 9ebd7fe, commit 4896089, commit c937d70 (22 Feb 2021) by Matheus Tavares (matheustavares).
(Merged by Junio C Hamano -- gitster -- in commit f277234, 25 Feb 2021)

add: propagate --chmod errors to exit status

Signed-off-by: Matheus Tavares
Reviewed-by: Taylor Blau

If add encounters an error while applying the --chmod changes, it prints a message to stderr, but exits with a success code.
This might have been an oversight, as the command does exit with a non-zero code in other situations where it cannot (or refuses to) update all of the requested paths (e.g. when some of the given paths are ignored).
So make the exit behavior more consistent by also propagating --chmod errors to the exit status.

And:

add --chmod: don't update index when --dry-run is used

Helped-by: Junio C Hamano
Signed-off-by: Matheus Tavares
Reviewed-by: Taylor Blau

git add --chmod(man) applies the mode changes even when --dry-run is used.
Fix that and add some tests for this option combination.



Answered By - VonC
Answer Checked By - Katrina (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Sunday, August 21, 2022

[FIXED] What is the best way to load environment variables in your build

 August 21, 2022     bitbucket, bitbucket-pipelines, environment-variables, npm, webpack     No comments   

Issue

For a project I am working on I am setting up a BitBucket pipeline. Everything works great except for the environment vars. One of the usages of my env vars is the API_URL. I am loading the url by using process.env.API_URL. Locally this works great since it loads the .env file by using dotenv-webpack. However, in the pipeline I don't know what the best way is to load these vars. Should I add all the vars to Bitbucket and add export API_URL=$API_URL for every var in the pipeline file or are there better ways to load the vars?


Solution

Workspace, Repository, and Deployment variables is the way to go. Which one you need depends on scope you'd like these variables to cover (naming is pretty self-explanatory: some variables shouldn't change their values across your entire account; others only make sense to a particular repository; finally, some values are specific to a deployment environment).

Just define the variables in the Bitbucket UI or using API, and refer to their values from bitbucket-pipelines.yml or any script that you invoke from it. You don't need to add any export statements. Here's a very good doc explaining the details - https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/ - and User-defined variables section is particularly relevant to your question.

Alternatively, if you committed your .env file, you can simply export its contents all at once as per this StackOverflow answer.

Obviously, don't commit .env if it contains any sensitive values.



Answered By - esimonov
Answer Checked By - Mildred Charles (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Friday, August 19, 2022

[FIXED] how to change the environments in angular

 August 19, 2022     angular, api, bitbucket, build, environment-variables     No comments   

Issue

In my project I have 3 environment files (dev, staging, production). And I want to change the them for each dist folder (when deploying to dev I need the envi dev link to take the data from.. same for staging and prod) The files contains these

export const environment = {
  production: true,
  hmr: false,
  backend: false,
  staging: false,
  apiKey: 'prodKey',
  API_URL: "my backend link"
};

Of course the production is false in dev and staging envs.. I also added in angular.json this (same for staging)

"configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "namedChunks": false,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2mb",
                  "maximumError": "5mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "6kb",
                  "maximumError": "10kb"
                }
              ],
              "outputPath": "dist/production"
            },

But when I do build I usually commment a file and use the other to do build and deploy as here in my api file

import { environment } from 'src/environments/environment';

// import { environment } from "src//environments/environment.stage";
// import { environment } from "src//environments/environment.prod";

const API_URL = environment.API_URL;

commmands are: ng build and ng build --configuration=staging and ng build --prod

But I dont want to keep commenting the API envir.. as above, I want it to change automatically after I do build and change in dist files for each environment so I can deploy normally to git and do normal pipeline.

Any idea? Thanks


Solution

Leave all imports as

import { environment } from 'src/environments/environment';

Extend the configurations object in angular.json

extending the configurations object:

... // angular.json
configurations": {
    "production" {...} // leave as it is,
    "dev": {
        "fileReplacements": [
            {
                "replace": "src/environments/environment.ts",
                "with": "src/environments/environment.dev.ts"
            }
        ]
    },
    "staging": {
        "fileReplacements": [
            {
                "replace": "src/environments/environment.ts",
                "with": "src/environments/environment.staging.ts"
            }
        ]
    }
}


Answered By - Andrew Allen
Answer Checked By - David Goodson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Sunday, January 30, 2022

[FIXED] Installing laravel on existing project

 January 30, 2022     bitbucket, composer-php, git, laravel, php     No comments   

Issue

I'm developing a laravel application and my computer die. Now I want to get my project from the repository (Bitbucket + Git) but thanks to the git ignore file, the vendor folder is missing. I can't do a composer install on my project because is not allowed (the directory should be empty). The structure of my project is the same as the laravel installation except that I renamed the public folder.

I found this thread but did not solve my problem.

Integrating existing project by laravel framework?

I wanna know the best practice or way to do this and i don't think that copy and paste the folder of my project to a fresh install of larevel should be the way.

Thanks.


Solution

Go to your www folder

cd /var/www

Git clone your application (not that here the directory must not exist):

git clone https://github.com/antonioribeiro/application

CD into the folder

cd application

Execute composer update (if you are in a development environment)

composer update

Or execute composer install (if you are in a production environment)

composer install

Note that for composer install or composer update, the folder may actually have files and even a vendor folder created, there is not such obstacle.



Answered By - Antonio Carlos Ribeiro
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Saturday, January 29, 2022

[FIXED] Getting a "No such remote or remote group" error when trying to use a private repo in Composer

 January 29, 2022     bitbucket, composer-php, php     No comments   

Issue

I'm getting an error when I try to run composer. I have the following in my composer.json:

{
    "require": {
        "my/private-repo": "dev-development"
    },
    "repositories": [
            {
            "type": "git",
            "url": "git@bitbucket.org:my/private-repo.git"
        }
    ],
}

In that private bitbucket repo, there's a composer.json with a name of "my/private-repo", and there's a branch called development.

When I try to run composer, I get this error: "Failed to update git@bitbucket.org:my/private-repo.git, package information from this repository may be outdated (fatal: No such remote or remote group: origin". I have no idea why it's mentioning origin at all; I've got that private repo in a totally separate folder on this composer, so it shouldn't be looking in there. I can git clone my/private-repo just fine, so it's not an SSH issue. Any ideas?


Solution

So it turns out this was just an issue with Composer caching. I ran rm -rf ~/.composer/cache/ and tried updating again, and everything works.



Answered By - greggilbert
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Friday, January 21, 2022

[FIXED] Is it possible to use composer's archive feature to compress a project locally?

 January 21, 2022     bitbucket, bitbucket-pipelines, composer-php, php     No comments   

Issue

Is it possible to use composer's archive feature to compress a project locally (similar to using zip)? For instance, I tried composer archive my-repo/project --format=zip --file test-archive. It worked in the sense that it created a zip file called test-archive, but composer did it by first going to my satis repo and pulling down a copy of the project.

I also have this defined in my composer.json

"archive": {
        "exclude": [
            ".*",
            "!.gitignore",
            "node_modules/",
            "vendor/",
            "www/",
            "composer/",
            "*.lst",
            "*.yml"
        ]
    }

What I'm trying to do is use the archive feature as part of a bitbucket pipelines build process. The goal is to compress the project files (excluding some) and pass them to the Downloads page for the bitbucket repo. I have a working step using zip, but archive uses a better syntax for excluding files.


Solution

Ok - now I feel a little silly, but since someone kindly upvoted the question, I'll answer it. The documentation was slightly confusing to me. Composer doesn't actually need my-repo/project to compress the file correctly. So if you do composer archive --format=zip --file test-archive it will compress in place at the root of your project.



Answered By - aberkow
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing