Category Archives: GoCD

GOCD – Basic user password login and API (authentication)

1. generate password hash
$ php -r 'echo base64_encode(sha1("badger", true));'
ThmbShxAtJepX80c2JY1FzOEmUk=

2. create password file
sudo -u go touch /etc/go/passwd
echo "<username>:<password hash>" > /etc/go/passwd

3. enable password file
Admin -> Server Configuration -> User Management -> Password File Settings -> Password File Path -> /etc/go/passwd -> Save

used links:
https://docs.go.cd/current/configuration/dev_authentication.html

Clean GOCD history

On GOCD server.
Stop go-server
Run this:

java -cp "/var/lib/go-server/work/jetty-0.0.0.0-8153-cruise.war-_go-any-/webapp/WEB-INF/lib/*:/var/lib/go-server/work/jett0.0.0.0-8153-cruise.war-_go-any-/webapp/WEB-INF/classes/" org.h2.tools.Console

Navigate to http://localhost:8082/
connect to jdbc:h2:/var/lib/go-server/db/h2db/cruise
Erase all data from database.
Run this several times:

DROP TRIGGER PUBLIC.LASTTRANSITIONEDTIMEUPDATE;
DELETE FROM PIPELINEMATERIALREVISIONS;
DELETE FROM MODIFICATIONS;
DELETE FROM MODIFIEDFILES;
DELETE FROM BUILDSTATETRANSITIONS;
DELETE FROM BUILDS;
DELETE FROM PROPERTIES;
DELETE FROM ENVIRONMENTVARIABLES;
DELETE FROM STAGES;
DELETE FROM PIPELINES;
UPDATE PIPELINELABELCOUNTS SET LABELCOUNT=0;
CREATE FORCE TRIGGER PUBLIC.LASTTRANSITIONEDTIMEUPDATE AFTER INSERT ON PUBLIC.BUILDSTATETRANSITIONS FOR EACH ROW QUEUE 1024 CALL "com.thoughtworks.go.server.sqlmigration.Migration_230007";

Send Ctrl-C to java … h2.Console. Or go-server will fail to start.
Erase all history files

rm -rf /var/lib/go-server/artifacts/pipelines/*/*
rm -rf /var/lib/go-server/pipelines/flyweight/*